This Twilio Function is based on the Twimlet of the same name.
It can be used as a drop-in replacement for the Twimlet, by using the URL of the Twilio Function as a webhook with the same GET parameters.
Alternatively, it can be customized by setting properties in the environment. GET and POST parameters are considered first, if provided, then environment properties, then config properties declared in the script.
Environment properties are most convenient when you are using a single instance of this script in your account. To customize multiple instances, the recommended way is to modify the script parameters in the config object, directly in the script.
The Simple Menu Funlet has two stages:
Stage | Addressing | Description |
---|---|---|
1 | Caller | Welcome the caller and gather digits |
2 | Caller | Redirect to the matching option, if any |
These two stages would typically be implemented in two separate Twilio Functions. In the Simple Menu Funlet, they are running in two separate instances of the same Twilio Function. This is in line with the original Simple Menu Twimlet, which implemented both stages in the same script.
Text string, a recording URL or a text to say. (A string starting with 'http' is considered to be a URL)
- Event:
Message
parameter - Environment:
FUNLET_MENU_MESSAGE
environment property - Script:
message
config property
Text string, a recording URL or a text to say when the digits pressed do not match any option. For a text message, the same language and voice will be used as for the message in stage 1.
- Event:
ErrorMessage
parameter - Environment:
FUNLET_MENU_ERROR_MESSAGE
environment property - Script:
errorMessage
config property
Text string, language code for text messages, e.g. 'en' or 'en-gb'. Defaults to 'en': English with an American accent.
- Event:
Language
parameter - Environment:
FUNLET_MENU_LANGUAGE
environment property - Script:
language
config property
Text string, voice for text messages, one of 'man', 'woman' or 'alice'. Defaults to 'alice', who speaks in a large selection languages.
- Event:
Voice
parameter - Environment:
FUNLET_MENU_VOICE
environment property - Script:
voice
config property
A list of action URLs to redirect to when the matching digits are input.
The digits are assigned by setting a custom key for the array index,
for example: Options[42]=http://example.com/action
associates the
action URL http://example.com/action
with the digits 42
.
Note that when no key is assigned, as in Options[]=//example.com/action
, a
sequence of digits starting with 0, not 1, will be associated with each option.
- Event: a list of
Options[digits]=URL
parameters: e.g.Options[1]=...&Options[2]=...&Options[101]=...
or a singleOptions=URL
string parameter, associated with digit0
. - Environment: up to 10 action URL and matching digits, each in a separate environment property:
FUNLET_MENU_OPTION1_URL
andFUNLET_MENU_OPTION1_DIGITS
FUNLET_MENU_OPTION2_URL
andFUNLET_MENU_OPTION2_DIGITS
- ...
FUNLET_MENU_OPTION9_URL
andFUNLET_MENU_OPTION9_DIGITS
FUNLET_MENU_OPTION0_URL
andFUNLET_MENU_OPTION0_DIGITS
If the environment property for an option URL is set without the environment property for the matching digits, the digits default to the number of the option: 1, 2, ..., 9, 0.
- Script:
options
config property with key/values for digits/URLs
Text string, list of digits pressed.
- Event:
Digits
property provided by<Gather>
This Twilio Function returns TwiML instructions for Twilio Voice.