Layer 2: Mobile Primitives
Layer 3 contains the specification for I/O blocks that represent discrete single actions, that have direct analogues across several channels used in mobile messaging (e.g. IVR, SMS, USSD). Support for this layer should be implemented by all engines that target the IVR
, TEXT
(SMS and USSD), and RICH_MESSAGING
modes. These blocks may make use of the Expression Specification for generating output. Higher levels may make use of embedded Layer 3 primitives to describe more advanced functionality.
Namespace: MobilePrimitives
Contents
Message Block
Type:
MobilePrimitives.Message
Suggested number of exits: 1
Supported modes:
IVR
,TEXT
,RICH_MESSAGING
,OFFLINE
This block presents a single message to the contact. The form of the message can depend on the mode: e.g. a voice recording for the IVR
mode, and text for the TEXT
mode.
Block config
config
prompt
(resource)
The content to be output. This is a localized resource; it supports parsing of expressions in rendering.
Detailed behaviour by mode
SMS
(SMS): Sendsprompt
as an SMS to the contact.USSD
(USSD): Displaysprompt
as the next USSD prompt to the user. (Note on USSD session management: If there are following blocks in the flow, the user has an opportunity to reply with anything to proceed. If there are no following blocks, the contact is prompted to dismiss the session.)IVR
: Playsprompt
to the contact.RICH_MESSAGING
: Displayprompt
within the conversation with the contact. Optionally, platforms may attach the audio from theprompt
resource (if provided) so that the contact can choose to play it.OFFLINE
: Displayprompt
within the session with the contact.
Output behaviour
None
Example
Select One Response (Multiple Choice Question) Block
Type:
MobilePrimitives.SelectOneResponse
Suggested number of exits: 1 + default exit (used in case of error or invalid input), or multiple exits based on choices
Supported modes:
IVR
,TEXT
,RICH_MESSAGING
,OFFLINE
This block obtains the answer to a Multiple Choice question from the contact. The contact must choose a single choice from a set of choices.
This block can be configured to have a single exit, or a number of exits with possibilities based on the response given. The exit specification is as described in Block exits
.
Block config
config
prompt
(resource, optional)
The question prompt that should be displayed to the contact, e.g. "What is your favorite kind of ice cream? Reply 1 for chocolate, 2 for vanilla, and 3 for strawberry." Either prompt
or question_prompt
should be provided. (For legacy compatibility, implementations may omit prompts completely when guidance has been given to the Contact in a previous block, but this is not recommended. In this case, the block will wait silently for a response.)
question_prompt
(resource, optional)
For instances when the question prompt should be separated from the presentation of choices, e.g. "What is your favorite kind of ice cream?". If included, blocks must provide suitable resources within choices
to present the choices on each supported mode. For the IVR
mode, they must also provide digit_prompts
.
choices
(array of choices)
Set of choices to select from. See choices configuration below.
Choices configuration
Each choice in choices
has the following elements:
name
(string)
Key identifying this choice. This is what will be written into the block output (block.value
) when a contact selects this choice, e.g. "chocolate" or "Somewhat Agree".
ivr_test
(object, optional)
See below.
text_tests
(array of objects, optional)
See below
prompt
(resource, optional)
Resource used to present/display/announce this choice to contacts, appropriate for the language and mode.
ivr_test
object
This test applies to IVR flows.
test_expression
(expression)
The first choice with an expression that evaluates to a truthy value is the selected choice. Often this expression would examine the raw response from the contact, e.g. "block.response = 1". IVR responses are not expected to vary across languages, so this test applies to all. ).
text_tests
object
These tests apply to non-IVR flows. There may be multiple tests per choice: any matching test will indicate that the choice has been selected.
language
(string, optional)
test_expression
(expression)
The first choice with an expression that evaluates to a truthy value is the selected choice. Often this expression would examine the raw response from the contact, e.g. "block.response = 1".
Channel-specific config
:
config
:IVR
: digit_prompts
(array of resources)
An ordered set of audio prompts, with the same length as choices
, with content such as "Press 1", "Press 2", "Press 3". This is required when using question_prompt
to present choices individually.
IVR
: randomize_choice_order
(boolean, optional)
Indicates that the choices should be presented in a random order to each Contact. (Used to minimize response order bias in surveying). Default false. Requires the use of question_prompt
, choices_prompt
, and IVR.digit_prompts
to present choices individually.
Detailed behaviour by mode
TEXT
(SMS): Send an SMS with the prompt text, according to the prompt configuration inconfig
above, and wait to capture a response. (Lack a response after the flow's configuredtimeout
, or an invalid response: proceed through the default exit.)TEXT
(USSD): Display a USSD menu prompt with the prompt text, according to the prompt configuration inconfig
above, then wait to capture the menu response. (Dismissal of the session, timeout, or invalid response: proceed through the default exit.)IVR
: Play the prompt, according to the prompt configuration inconfig
above, then wait to capture the DTMF response. (Timeout or invalid response: proceed through the default exit.)When
question_prompt
is provided,prompt
is ignored, and the prompt presented to the contact is generated as follows:"What is your favorite kind of ice cream?" "For chocolate," "Press 1". "For vanilla", "Press 2". "For strawberry," "Press 3".
<question_prompt>
<choices["chocolate"]>
<digit_prompts[0]>
<choices["vanilla"]>
<digit_prompts[1]>
<choices["strawberry"]>
<digit_prompts[2]>
RICH_MESSAGING
: Display the prompt text according to the prompt configuration inconfig
above. Platforms may wait to capture a text response, or display rich menu items for each choice and wait to capture a menu choice. (If displaying menu items, platforms should display onlyquestion_prompt
.) (Timeout or invalid response: proceed through the default exit.)OFFLINE
: Display the prompt text according toquestion_prompt
, and a menu of items for allchoices
. Wait to capture a menu selection.
Output behaviour
This block writes the name
of the selected choice to the output variable corresponding to the name
of the block.
Example
Select Many Responses (Multiple Choice Question) Block
Type:
MobilePrimitives.SelectManyResponses
Suggested number of exits: 1 + default exit (used in case of error or invalid input).
Supported modes:
IVR
,TEXT
,RICH_MESSAGING
,OFFLINE
This block obtains the answer to a Multiple Choice question from the contact. The contact can select from zero to many options from a set of choices.
Block config
config
prompt
(resource, optional)
The question prompt that should be displayed to the contact, e.g. "What kinds of ice cream do you like: chocolate, vanilla, strawberry? Select all that apply." Either prompt
or question_prompt
should be provided. (For legacy compatibility, implementations may omit prompts completely when guidance has been given to the Contact in a previous block, but this is not recommended. In this case, the block will wait silently for a response.)
question_prompt
(resource, optional)
For instances when the question prompt should be separated from the presentation of choices, e.g. "What is your favorite kind of ice cream?". If included, blocks must provide suitable resources within choices
to present the choices on each supported mode. For the IVR
mode, they must also provide digit_prompts
.
choices
(array of choices)
Set of choices to select from. See choices configuration below.
minimum_choices
(integer, optional)
The minimum number of choices the Contact must select to proceed. Default if not provided: 0.
maximum_choices
(integer, optional)
The maximum number of choices the Contact can select. Default if not provided: unlimited (ie: the total number of choices
).
Choices configuration
Each choice in choices
has the following elements:
name
(string)
Key identifying this choice. This is what will be written into the block output (block.value
) when a contact selects this choice, e.g. "chocolate" or "Somewhat Agree".
ivr_test
(object, optional)
See below.
text_tests
(array of objects, optional)
See below
prompt
(resource)
Resource used to present/display/announce this choice to contacts, appropriate for the language and mode.
This block can be configured to have a single exit, or a number of exits with possibilities based on the response given. The exit specification is as described in Block exits
.
ivr_test
object
This test applies to IVR flows.
test_expression
(expression)
The first choice with an expression that evaluates to a truthy value is the selected choice. Often this expression would examine the raw response from the contact, e.g. "block.response = 1". IVR responses are not expected to vary across languages, so this test applies to all. ).
text_tests
object
These tests apply to non-IVR flows. There may be multiple tests per choice: any matching test will indicate that the choice has been selected.
language
(string, optional)
test_expression
(expression)
The first choice with an expression that evaluates to a truthy value is the selected choice. Often this expression would examine the raw response from the contact, e.g. "block.response = 1".
Channel-specific config
:
config
:IVR
: digit_prompts
(array of resources)
An ordered set of audio prompts, with the same length as choices
, with content such as "Press 1", "Press 2", "Press 3". This is required when using question_prompt
to present choices individually.
IVR
: randomize_choice_order
(boolean, optional)
Indicates that the choices should be presented in a random order to each Contact. (Used to minimize response order bias in surveying). Default false. Requires the use of question_prompt
, choices_prompt
, and IVR.digit_prompts
to present choices individually.
Detailed behaviour by mode
TEXT
(SMS): Send an SMS with the prompt text, according to the prompt configuration inconfig
above, and wait to capture multiple responses. (Lack of the right number of responses after the flow's configuredtimeout
, or an invalid response: proceed through the default exit.)TEXT
(USSD): Display a USSD menu prompt with the prompt text, according to the prompt configuration inconfig
above, then wait to capture text describing multiple choices. (Dismissal of the session, timeout, or invalid response: proceed through the default exit.)IVR
: Play the prompt, according to the prompt configuration inconfig
above, then wait to capture multiple DTMF responses. Implementations may choose to optimize the user experience for additional guidance on answering multiple options. (Timeout or invalid response: proceed through the default exit.)When
question_prompt
is provided,prompt
is ignored, and the prompt presented to the contact is generated as follows:"What is your favorite kind of ice cream?" "For chocolate," "Press 1". "For vanilla", "Press 2". "For strawberry," "Press 3".
<question_prompt>
<choices["chocolate"]>
<digit_prompts[0]>
<choices["vanilla"]>
<digit_prompts[1]>
<choices["strawberry"]>
<digit_prompts[2]>
RICH_MESSAGING
: Display the prompt text according to the prompt configuration inconfig
above. Platforms may wait to capture a text response, or display rich menu items for each choice and wait to capture a menu choice. (If displaying menu items, platforms should display onlyquestion_prompt
.) (Timeout or invalid response: proceed through the default exit.)OFFLINE
: Display the prompt text according toquestion_prompt
, and a menu of items for allchoices
. Wait to receive a menu confirmation.
Output behaviour
This block writes an array of name
s of the selected choices to the output variable corresponding to the name
of the block.
Example
Numeric Response Block
Type:
MobilePrimitives.NumericResponse
Suggested number of exits: 1 + default exit (used in case of error or invalid input), or multiple based on ranges of interest
Supported modes:
IVR
,TEXT
,RICH_MESSAGING
,OFFLINE
This block obtains a numeric response from the contact.
Block config
config
prompt
(resource, optional)
The question prompt that should be displayed to the contact, e.g. "How old are you? Please reply with your age in years." (For legacy compatibility, implementations may omit the prompt when guidance has been given to the Contact in a previous block, but this is not recommended. In this case, the block will wait silently for a response.)
validation_minimum
(number, optional)
The minimum value (inclusive) that will be accepted as a response to this block; responses less than this will result in a block value of null
.
validation_maximum
(number, optional)
The maximum value (inclusive) that will be accepted as a response to this block; responses greater than this will result in a block value of null
.
Channel-specific config
:
config
:IVR
: max_digits
(number)
After receiving this many digits, do not wait for any more; accept the digits entered so far as the complete response.
This block can be configured to have a single exit, or a number of exits with possibilities based on the range of the numeric response given. The exit specification is as described in Block exits
.
Detailed behaviour by mode
TEXT
(SMS): Send an SMS with the prompt text, according to the prompt configuration inconfig
above, and wait to capture a response. (Lack a response after the flow's configuredtimeout
, or an invalid response: proceed through the default exit.)TEXT
(USSD): Display a USSD menu prompt with the prompt text, according to the prompt configuration inconfig
above, then wait to capture the menu response. (Dismissal of the session, timeout, or invalid response: proceed through the default exit.)IVR
: Play the prompt, according to the prompt configuration inconfig
above, then wait to capture the DTMF response. (Timeout or invalid response: proceed through the default exit.)RICH_MESSAGING
: Display the prompt text according to the prompt configuration inconfig
above. Platforms may wait to capture a text response, or display a numeric entry widget and wait to capture a response. (Timeout or invalid response: proceed through the default exit.)OFFLINE
: Display the prompt text according to the prompt configuration inconfig
above, and display a numeric entry widget. Wait to capture a response.
Output behaviour
This block writes the numeric value received to the output variable corresponding to the name
of the block.
Example
Open Response Block
Type:
MobilePrimitives.OpenResponse
Suggested number of exits: 1 + default exit (used in case of error or invalid input), or multiple based on patterns of interest
Supported modes:
IVR
,TEXT
,RICH_MESSAGING
,OFFLINE
This block obtains an open-ended response from the contact. Dependent on the mode, this is a TEXT response, audio recording, or other type of media recording (e.g. video).
This block can be configured to have a single exit, or a number of exits with possibilities based on patterns in the response given. The exit specification is as described in Block exits
.
Block config
config
prompt
(resource, optional)
The question prompt that should be displayed to the contact, e.g. "Please leave us feedback on your experience at the Childrens Hospital." (For legacy compatibility, implementations may omit the prompt when guidance has been given to the Contact in a previous block, but this is not recommended. In this case, the block will wait silently for a response.)
Channel-specific config
:
config
:IVR
: max_duration_seconds
(number)
The maximum duration to record for, before proceeding to the next block.
IVR
: end_recording_digits
(string, optional)
A set of key-press digits that terminate an open-ended recording, e.g.: "1789#"
Detailed behaviour by mode
TEXT
(SMS): Send an SMS with the prompt text, according to the prompt configuration inconfig
above, and wait to capture a response. (Invalid/empty response: proceed through the default exit.)TEXT
(USSD): Display a USSD menu prompt with the prompt text, according to the prompt configuration inconfig
above, then wait to capture the menu response. (Invalid/empty response: proceed through the default exit.)IVR
: Play the prompt, according to the prompt configuration inconfig
above, then record the user's response. (Timeout with nothing recorded: proceed through the default exit.)RICH_MESSAGING
: Display the prompt text according to the prompt configuration inconfig
above, and wait to capture a text response or an upload (audio, video) from the contact. (Invalid/empty response: proceed through the default exit.)OFFLINE
: Display the prompt text according to the prompt configuration inconfig
above, and display a text entry widget. Wait to capture a response.
Output behaviour
For TEXT
, OFFLINE
, and RICH_MESSAGING
modes that capture a text response, this block writes the text received to the output variable corresponding to the name
of the block. For responses captured as media (IVR
, RICH_MESSAGING
) the ID or URL of the recording is written.
Example
Last updated