<Sms>

The <Sms> verb sends an SMS message to a phone number during a phone call.

Verb Attributes

Attribute
to optionalThe to attribute takes a valid phone number as a value. SignalWire will send an SMS message to this number.

When sending an SMS during an incoming call, to defaults to the caller. When sending an SMS during an outgoing call, to defaults to the called party. The value of to must be a valid phone number. NOTE: sending to short codes is not currently supported.

Phone numbers should be formatted with a + and country code e.g., +17275551212 (E.164 format).
from optionalThe from attribute takes a valid phone number as an argument. This number must be a phone number that you've purchased from or ported to SignalWire. When sending an SMS during an incoming call, from defaults to the called party. When sending an SMS during an outgoing call, from defaults to the calling party. This number must be an SMS-enabled phone number assigned to your account. If the phone number isn't SMS-enabled, then the <Sms> verb will not send an SMS message.
action optionalThe action attribute takes a URL as an argument. After processing the <Sms> verb, SignalWire will make a GET or POST request to this URL with the form parameters SmsStatus and SmsSid. Using an action URL, your application can receive synchronous notification that the message was successfully enqueued.

If you provide an action URL, SignalWire will use the LaML received in your response to the action URL request to continue the current call. Any LaML verbs occurring after an <Sms> which specifies an action attribute are unreachable.

If no action is provided, <Sms> will finish and SignalWire will move on to the next LaML verb in the document. If there is no next verb, SignalWire will end the phone call. Note that this is different from the behavior of <Record> and <Gather>. <Sms> does not make a request to the current document's URL by default if no action URL is provided. See below for request parameters.
method optionalThe method attribute specifies whether the request to action is a GET or a POST. Valid values are GET or POST, default value is POST. `
statusCallback optionalThe URL to make requests to for each statusCallbackEvent event. See below for request parameters. The statusCallback attribute takes a URL as an argument. When the SMS message is actually sent, or if sending fails, SignalWire will make an asynchronous POST request to this URL with the parameters SmsStatus and SmsSid. Note, statusCallback always uses HTTP POST to request the given url.

Request parameters for the action URL

The action URL request contains the Standard Request Parameters as well as:

Parameter
SmsSid stringThe Sid for the Sms message.
SmsStatus stringThe current status of the Sms message. This is usually sending. But if you provide an invalid number, this is invalid.

Request parameters for statusCallback

The statusCallback request contains the Standard Request Parameters as well as:

Parameter
SmsSid stringThe Sid for the Sms message.
SmsStatus stringThe current status of the Sms message. Either sent or failed.

Nouns

The noun of a LaML verb is nested within the verb upon which the verb acts. <Sms> has the following nouns:

Noun
plain textThe text of the SMS message you want to send. Must be less than 1600 characters.

Nesting

No other verbs can be nested within <Sms> and you cannot nest <Sms> within any other verbs.

Examples

Simple SMS Sending

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say>Our store is located at 123 Easy St.</Say>
    <Sms>Store Location: 123 Easy St.</Sms>
</Response>
const { RestClient } = require('@signalwire/node')
const response = new RestClient.LaML.VoiceResponse()

response.say('Our store is located at 123 Easy St.');
response.sms('Store Location: 123 Easy St.');

console.log(response.toString());
<?php
  use SignalWire\LaML;
  $response = new LaML;
  $response->say('Our store is located at 123 Easy St.');
  $response->sms('Store Location: 123 Easy St.');

  echo $response;
?>
using System;
using Twilio.TwiML;
using Twilio.TwiML.Voice;


class Example
{
    static void Main()
    {
        var response = new VoiceResponse();
        response.Say("Our store is located at 123 Easy St.");
        response.Sms("Store Location: 123 Easy St.");

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

response = VoiceResponse()
response.say('Our store is located at 123 Easy St.')
response.sms('Store Location: 123 Easy St.')

print(response)
require 'signalwire/sdk'

response =  Signalwire::Sdk::VoiceResponse.new
response.say(message: 'Our store is located at 123 Easy St.')
response.sms('Store Location: 123 Easy St.')

puts response

This is the simplest case for <Sms>. SignalWire first tells the caller where the store is located, and then sends the caller an SMS with the location as the message.

SmsStatus reporting

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say>Our store is located at 123 Easy St.</Say>
    <Sms action="/smsHandler.php" method="POST">
        Store Location: 123 Easy St.
    </Sms>
</Response>
const { RestClient } = require('@signalwire/node')
const response = new RestClient.LaML.VoiceResponse()

response.say('Our store is located at 123 Easy St.');
response.sms({
    action: '/smsHandler.php',
    method: 'POST'
}, 'Store Location: 123 Easy St.');

console.log(response.toString());
<?php
  use SignalWire\LaML;
  $response = new LaML;
  $response->say('Our store is located at 123 Easy St.');
  $response->sms('Store Location: 123 Easy St.', ['action' => '/smsHandler.php',
    'method' => 'POST']);


  echo $response;
?>
using System;
using Twilio.TwiML;
using Twilio.TwiML.Voice;


class Example
{
    static void Main()
    {
        var response = new VoiceResponse();
        response.Say("Our store is located at 123 Easy St.");
        response.Sms("Store Location: 123 Easy St.",
            action: new Uri("/smsHandler.php"), method: Twilio.Http.HttpMethod
            .Post);

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

response = VoiceResponse()
response.say('Our store is located at 123 Easy St.')
response.sms(
    'Store Location: 123 Easy St.', action='/smsHandler.php', method='POST'
)
print(response)
require 'signalwire/sdk'

response =  Signalwire::Sdk::VoiceResponse.new
response.say(message: 'Our store is located at 123 Easy St.')
response.sms('Store Location: 123 Easy St.', action: '/smsHandler.php',
                                             method: 'POST')

puts response

In this use case, we provide action URL and method attributes. Now when the message is queued for delivery, SignalWire will make a request to the action URL passing the parameter SmsStatus. If the message is queued and waiting to be sent, SmsStatus will have the value sending. If an invalid attribute was provided, then SmsStatus will be invalid.

Your web application can look at the SmsStatus parameter and decide what to do next.

If an action URL is provided for <Sms>, flow of your application will continue with the TwiML received in response to the action request. All verbs remaining in the document are unreachable and ignored.

statusCallback reporting

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say>Our store is located at 123 Easy St.</Say>
    <Sms statusCallback="/smsHandler.php">Store Location: 123 Easy St.</Sms>
</Response>
const { RestClient } = require('@signalwire/node')
const response = new RestClient.LaML.VoiceResponse()

response.say('Our store is located at 123 Easy St.');
response.sms({
    statusCallback: '/smsHandler.php'
}, 'Store Location: 123 Easy St.');

console.log(response.toString());
<?php
  use SignalWire\LaML;
  $response = new LaML;
  $response->say('Our store is located at 123 Easy St.');
  $response->sms('Store Location: 123 Easy St.',
    ['statusCallback' => '/smsHandler.php']);

  echo $response;
?>
using System;
using Twilio.TwiML;
using Twilio.TwiML.Voice;


class Example
{
    static void Main()
    {
        var response = new VoiceResponse();
        response.Say("Our store is located at 123 Easy St.");
        response.Sms("Store Location: 123 Easy St.",
            statusCallback: new Uri("/smsHandler.php"));

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

response = VoiceResponse()
response.say('Our store is located at 123 Easy St.')
response.sms('Store Location: 123 Easy St.', status_callback='/smsHandler.php')

print(response)
require 'signalwire/sdk'

response =  Signalwire::Sdk::VoiceResponse.new
response.say(message: 'Our store is located at 123 Easy St.')
response.sms('Store Location: 123 Easy St.', status_callback: '/smsHandler.php')

puts response

In this example we provide a statusCallback URL. When the message is finished sending (not just enqueued), SignalWire will asynchronously request the statusCallback URL with the parameter SmsStatus. If the messages was successfully sent, SmsStatus will be sent. If the message failed to send, SmsStatus will be failed.