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:
Messageparameter - Environment:
FUNLET_MENU_MESSAGEenvironment property - Script:
messageconfig 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:
ErrorMessageparameter - Environment:
FUNLET_MENU_ERROR_MESSAGEenvironment property - Script:
errorMessageconfig property
Text string, language code for text messages, e.g. 'en' or 'en-gb'. Defaults to 'en': English with an American accent.
- Event:
Languageparameter - Environment:
FUNLET_MENU_LANGUAGEenvironment property - Script:
languageconfig property
Text string, voice for text messages, one of 'man', 'woman' or 'alice'. Defaults to 'alice', who speaks in a large selection languages.
- Event:
Voiceparameter - Environment:
FUNLET_MENU_VOICEenvironment property - Script:
voiceconfig 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]=URLparameters: e.g.Options[1]=...&Options[2]=...&Options[101]=...or a singleOptions=URLstring parameter, associated with digit0. - Environment: up to 10 action URL and matching digits, each in a separate environment property:
FUNLET_MENU_OPTION1_URLandFUNLET_MENU_OPTION1_DIGITSFUNLET_MENU_OPTION2_URLandFUNLET_MENU_OPTION2_DIGITS- ...
FUNLET_MENU_OPTION9_URLandFUNLET_MENU_OPTION9_DIGITSFUNLET_MENU_OPTION0_URLandFUNLET_MENU_OPTION0_DIGITSIf 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:
optionsconfig property with key/values for digits/URLs
Text string, list of digits pressed.
- Event:
Digitsproperty provided by<Gather>
This Twilio Function returns TwiML instructions for Twilio Voice.