Receive SMS action

The Receive SMS action is technically a wait action with sms_received as its criterion.

This action only works in the Mobile agent. Non-mobile agents ignore SMS actions; during playback, the Recorder ignores these actions.

This action requires you to specify the SMS sender (phone number) or SMS message. The Mobile agent is blocked until it either receives an SMS containing the specified number and/or message, or until it reaches the wait timeout threshold and fails.

The Receive SMS action has the following properties:

smsSender

The phone number sending the SMS message to the Mobile agent. This can be either a standard phone number or a short number.

smsMessage

The string that the agent uses to validate within the SMS reply message

replyHandler

The Receive SMS action accepts Reply Handler JavaScript code to intercept and capture information from the SMS reply. This functionality can be helpful in the following use cases:

  • The user wants to capture the phone number sending the SMS to use in a following action; for example, to reply to the sender in a subsequent Send SMS action.

  • The user wants to capture the SMS reply message (or part of the message) to use at a later point in the script. For example, the SMS reply contains a dynamically generated validation code that the user needs capture and then input into a web form (via a FormFill action) later on in the script.

  • The user needs to run some custom JavaScript if the SMS reply passes or fails.

The SMS Reply Handler API provides access to the response code for the SMS reply, the phone number sending the reply, and the message content of the SMS reply. These can be used along with standard JavaScript and any of the other methods outlined in this guide to create scripts customized based on the SMS reply content.

The SMS Reply Hander API is provided in the appendix. For more information, see Recorder API.