Receive SMS script action

SMS actions only apply to scripts configured for mobile devices.

When a mobile script uses a Short Message Service (SMS) action, the mobile device sends a message to an application and/or receives a reply. You may send a message to a short code or a phone number, receive a message back from a phone number or with particular content, or you may navigate to a website where a Wireless Application Protocol (WAP) Push (which pushes URL notifications to a mobile device) is returned with a URL.

Use the Send SMS action to send an SMS and the Receive SMS action, described below, to receive a reply.

SMS actions only have an effect when executed on the Synthetic Mobile network. Running SMS actions in a script from the Recorder will result in successful actions without actually executing anything.

Add a Receive SMS action

  1. Hold the mouse cursor over the action separator timeline action separator in the time line where you want to add the action.

  2. Click the add icon  that appears to display the list of actions.

  3. Select Receive SMS.
    Select Receive SMS action

Define a Receive SMS action

Receive SMS settings

  1. If necessary, select the Details tab of the Receive SMS settings.

  2. In the Receive From field, enter the phone number of the mobile device that is to receive an SMS. Enter numbers only (no spaces or dashes) in either a local short or long number format. You cannot enter international phone numbers.

  3. In the Text to Match field, enter the message, up to 160 ASCII characters.

  4. The default timeout value, which is the maximum time to wait for a received message, is 60 seconds. Enter a different value, up to a maximum of 60 seconds, in the Timeout field.

When playing back transactions that include SMS actions, the Recorder assumes that it sends SMS messages successfully and receives a text message matching the criteria you provided. When the script runs on the Synthetic Mobile network, actual SMS messages will be sent and received.

Validate SMS content

Use the text of a SMS message (phone number and text) from an earlier step to validate future steps in a script.

Add reply handling

  1. Select the Reply Handler tab of the Receive SMS settings.
    Reply handler tab

  2. Enter the JavaScript. See the following section for more information.

Response API

eventType: replyReceived

response – reference the current reply object

Properties

  • status – The status code from the result (for example 200, 404, and so on).
  • headerNames – Returns an array of the header names that exist in the reply.
  • content – The reply content as a string.
  • contentBytes – The reply content as a byte array.

All response properties are read-only

Method

  • getHeader(name) – Returns the value of the header. If it does not exist, it will return null. If there are multiple headers with the same name, it will return a string with a list in which the items are separated by comma+space.

Example code for a reply handler

if (response.status == '200'){
    body = response.content;
    orderId = body.match(/orderId\=([0-9]+)/)[1];
}