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 Forward Funlet has two stages:
Stage | Addressing | Description |
---|---|---|
1 | Caller | Check that caller is allowed and forward the call |
2 | Caller | After a failed call, redirect to fallback URL, if any |
These two stages would typically be implemented in two separate Twilio Functions. In the Forward Funlet, they are running in two separate instances of the same Twilio Function. This is in line with the original Forward Twimlet, which implemented both stages in the same script.
Text string, the forwarding number.
- Event:
PhoneNumber
parameter - Environment:
FUNLET_FORWARD_PHONE_NUMBER
environment property - Script:
phoneNumber
config property
Text string, one of the verified phone numbers of your account that you want to appear as caller ID for the forwarded call.
- Event:
CallerId
parameter - Environment:
FUNLET_FORWARD_CALLER_ID
environment property - Script:
callerId
config property
Text string, fallback URL where further instructions are requested when the forwarding call fails.
- Event:
FailUrl
parameter - Environment:
FUNLET_FORWARD_FALLBACK_URL
environment property - Script:
fallbackUrl
config property
Number, duration in seconds to let the call ring before the recipient picks up.
- Event:
Timeout
parameter - Environment:
FUNLET_FORWARD_TIMEOUT
environment property - Script:
timeout
config property
A list of text strings with the only phone numbers of callers that will be allowed to be forwarded.
- Event: a single
AllowedCallers=
or a list ofAllowedCallers[]=
parameters - Environment: up to five allowed callers, each in a separate environment property:
FUNLET_FORWARD_ALLOWED_CALLER1
,FUNLET_FORWARD_ALLOWED_CALLER2
,FUNLET_FORWARD_ALLOWED_CALLER3
,FUNLET_FORWARD_ALLOWED_CALLER4
,FUNLET_FORWARD_ALLOWED_CALLER5
- Script:
allowedCallers
config property with an array of string values
Text string, a recording URL or a text to say when the calling number is not one of the allowed callers configured.
- Event:
AccessRestricted
- Environment:
FUNLET_FORWARD_ACCESS_RESTRICTED
environment property - Script:
accessRestricted
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_FORWARD_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_FORWARD_VOICE
environment property - Script:
voice
config property
Text string, the caller's phone number.
- Event:
From
orCaller
property provided by the Twilio Voice event
Text string, the Twilio phone number called for the forwarding.
- Event:
To
orCalled
property provided by the Twilio Voice event
Boolean, a flag set to true to bypass the first stage of processing when returning from the call to the forwarding number.
- Event:
Dial
parameter
Text string, the status of the forwarding call.
- Event:
DialCallStatus
orDialStatus
property provided by<Dial>
This Twilio Function returns TwiML instructions for Twilio Voice.