Voice XML

SignalWire Compatible XML is a set of actions defined in an XML document you can use to tell SignalWire what to do when you receive an incoming call or instructions for outbound calls.

When a call is made 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 call, and much more.

📘

Not making a call? Check out Messaging 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). The request includes contextual information about the call, allowing you to respond dynamically and fluidly to the call 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 call:

ParameterType
CallSidstringA unique identifier for the call.
AccountSidstringThe unique ID of the Account this call is associated with.
FromstringThe phone number that sent this call, in E.164 format.
TostringThe phone number of the call recipient, in E.164 format.
CallStatusstringThe status of the call. Can be one of the following values: ringing, in-progress, queued, failed, busy, no-answer, or completed.
ApiVersionstringThe version of the SignalWire API. Incoming calls use the API version placed on the number called. Outgoing calls use the version of the REST API request.
DirectionstringAn identifier to describe the direction of the call:
outbound-dial: calls launched through the <Dial> verb
outbound-api: calls launched through the REST API
inbound: for inbound calls
ParentCallSidstringA unique identifier for the call that created this call.

CallStatus Values

The following are the possible CallStatus parameter values. These are also used in <Dial>'s DialCallStatus:

Value
ringingThe call is ringing.
in-progressThe call was answered and is in progress.
queuedThe call is ready and in line to initiate.
failedThe call could not be completed. Usually occurs when phone number does not exist.
busyThe caller encountered a busy signal.
no-answerThe call ended without an answer.
completedThe call was answered and ended normally.
canceledThe REST API canceled the call while it was ringing or queued.

Responding to SignalWire

An example of a SignalWire Compatible XML document that reads a message to the caller before playing an audio file:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say>Hello, World!</Say>
    <Play>https://your-application.com/audio.mp3</Play>
</Response>
const { RestClient } = require('@signalwire/node')
const response = new RestClient.LaML.VoiceResponse()

response.say('Hello, World!')
response.play('https://your-application.com/audio.mp3')
console.log(response.toString())
<?php
  use SignalWire\LaML;
  $response = new LaML;

  $response->say('Hello, World!');
  $response->play('https://your-application.com/audio.mp3');
  echo $response;
?>
using Twilio.TwiML;
using System;


class Example
{
    static void Main()
    {
        var response = new VoiceResponse();
        response.Say("Hello, World!");
        response.Play(new Uri("https://your-application.com/audio.mp3"));

        Console.WriteLine(response.ToString());;
    }
}
from signalwire.voice_response import VoiceResponse, Say, Play

response = VoiceResponse()
response.say('Hello, World!')
response.play('https://your-application.com/audio.mp3')

print(response)
require 'signalwire/sdk'

response = Signalwire::Sdk::VoiceResponse.new do |response|
  response.say(message: 'Hello World!')
  response.play(url: 'https://your-application.com/audio.mp3')
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 your 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 <play> instead of <Play> will result in an error.

Status Callbacks

SignalWire can send your application callbacks at various lifecycle stages of your call. 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 call 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.

The StatusCallback request contains the Standard Request Parameters plus the following optional parameters:

ParameterType
ForwardedFromstringThe number this call was forwarded from.
CallerNamestringThe name of the caller. Only available if Caller ID lookup is enabled.
CallDurationintegerThe duration, in seconds, of the finished call. Only present on the completed event.
RecordingUrlstringThe URL of the recorded audio call.
RecordingSidstringThe unique identifier for the audio recording.
RecordingDurationintegerThe duration, in seconds, of the recording.
CallbackSourcestringThe source of the status callback.
TimestampstringThe timestamp, in RFC 2822 format, of when the event occurred.
SequenceNumberintegerThe order in which events occur. Starts at 0. Although events are fired in order, they each take time and may not appear in the order you expect.