Messaging XML

SignalWire Compatible XML is a set of actions defined in an XML document that you can use to tell SignalWire what to do when you receive an incoming SMS or MMS message.

Overview

When an SMS or MMS message is sent to one of your SignalWire phone numbers, SignalWire looks up the SignalWire Compatible XML document from the URL you configured, and reads the instructions you provided to determine what to do.

SignalWire Compatible XML allows you to dynamically control what happens, responding with specific instructions based on the caller, time of day, incoming message, and much more.

📘

Not sending SMS or MMS? SignalWire Compatible XML allows you to control calls as well. Check out Voice XML for more details.

Request For XML

SignalWire makes an HTTP request to your configured endpoint just like a regular web form submission (POST) or page load (GET). Including contextual information about the message in the request to your endpoint, allows you to respond dynamically and fluidly to the message to meet the needs of your application.

You can configure the endpoint URL and HTTP Method in your phone number settings panel on your SignalWire dashboard, or via the REST API.

Request Parameters

SignalWire sends the following parameters, as either URL query parameters or POST parameters, to your endpoint when it receives a message:

Parameter
MessageSid stringA unique identifier for the message. May be used to later retrieve this message from the REST API.
AccountSid stringThe unique ID of the Account this message is associated with.
From stringThe phone number that sent this message, in E.164 format.
To stringThe phone number of the message recipient, in E.164 format.
Body stringThe text body of the message.
NumMedia integerThe number of media items associated with the message.
MediaUrl{X} string
only if media present
The URL to the media received in the message. URLs are publicly available but unguessable. Each media entry has its own entry, where X is a zero-based index of the media. Example: MediaUrl0
MediaContentType{X} string
only if media present
The content-type of the media stored at MediaUrl{X}, where X is a zero-based index of the media. Example: MediaContentType0

Responding to SignalWire

An example SignalWire Compatible XML document that sends two messages back to the sender when a message is received:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Message>Hello from SignalWire!</Message>
    <Message>Thanks for your message.</Message>
</Response>
const { RestClient } = require('@signalwire/node')
const response = new RestClient.LaML.MessagingResponse()

response.message('Hello from SignalWire!')
response.message('Thanks for your message.')
console.log(response.toString())
<?php
  use SignalWire\LaML;
  $response = new LaML;

  $response->message('Hello from SignalWire!');
  $response->message('Thanks for your message.');
  echo $response;
?>
using Twilio.TwiML;
using System;


class Example
{
    static void Main()
    {
        var response = new MessagingResponse();
        response.Message("Hello from SignalWire!");
        response.Message("Thanks for your message.")

        Console.WriteLine(response.ToString());;
    }
}
from twilio.twiml.messaging_response import Message, MessagingResponse

response = MessagingResponse()
response.message('Hello from SignalWire!')
response.message('Thanks for your message.')

print(response)
require 'signalwire/sdk'

response = Signalwire::Sdk::MessagingResponse.new do |response|
  response.message(body: 'Hello from SignalWire!')
  response.message(body: 'Thanks for your message.')
end

puts response.to_s

When a message comes into one of your SignalWire phone numbers, SignalWire makes an HTTP request to the URL endpoint you configured for that number. Your response to that request instructs SignalWire on what to do next.

Responses to the HTTP request are in SignalWire Compatible XML. SignalWire starts at the top of SignalWire Compatible XML document and executes your XML commands in order, from top to bottom.

📘

SignalWire Compatible XML verbs and their attributes are case-sensitive, so using <message> instead of <Message> will result in an error.

Status Callbacks

SignalWire can send your application callbacks at various lifecycle stages of your message. Status callbacks do not allow you to change the application execution directly, so callbacks do not have to respond with SignalWire Compatible XML, but they allow your application to get updates as a message is happening.

You should respond to any callbacks with a 200 OK or 204 No Content, otherwise, you will see failures in your application log on SignalWire.

MIME Types

The following are the MIME types supported by SignalWire:

Type
audio/mp4mpeg layer 4 audio
audio/mpegmpeg layer 3 audio
audio/mpeg3mpeg layer 3 audio
audio/oggogg audio
audio/vorbisaudio compression format
audio/vnd.wavwav format audio
audio/ac3codec format audio
audio/amrcodec format audio
audio/midimusical instrument digital interface format
image/jpegjpeg format image
image/gifgraphics interchange format
image/pngportable network graphics format
image/bmpbitmap image format
text/plaintext file format
text/calendartext file format
text/vcardtext file format
text/x-vcardtext file format
video/mpegmpeg video format
video/mp4mpeg layer 4 video format
video/quicktimequicktime video
video/h264video compression format
video/3gpmedia container format