TwiML Redirect
Description:
TwiML Redirect allows you to redirect a Voice Call to be handled outside of Studio and optionally return control back to Studio.
Passing Parameters to the TwiML Redirect widget
If you want to pass parameters to the TwiML Redirect widget from your Studio flow, you can pass them in the query string, as part of the URL.
For example, if you wanted to pass the Digits
variable from the Gather widget, you would enter the following in the URL field for the TwiML Redirect widget:
https://example.com/myfunction?Digits={{widgets.MY_WIDGET_NAME.Digits}}
Returning control to Studio
To handle returning control to Studio, you need to specify a <Redirect>
to the Studio Webhook URL and append ?FlowEvent=return
. Any additional parameters specified in the return URL will be injected into the Studio context and addressable via Liquid template variables.
Example:
<Response> <Say>Returning you back to the Studio Flow.</Say> <Redirect>https://webhooks.twilio.com/v1/Accounts/{AccountSid}/Flows/{FlowSid}?FlowEvent=return&foo=bar</Redirect> </Response>
The URL parameter foo
illustrated above will be passed automatically into your Flow and can be referenced via Liquid as {{widgets.your_redirect_widget_name.foo}}
.
Tip: To retrieve the Studio Webhook URL, in your Studio flow, click the red Trigger widget. The URL starting with https://webhooks.twilio.com/v1/...
is the Webhook URL.
Required Configuration:
Name |
Description |
Default |
URL |
URL where the call or message will be redirected. |
None |
Optional Configuration:
Name |
Description |
Default |
Method |
HTTP method to be used in the redirect |
POST |
Timeout |
Number of seconds to wait for control to be returned to Studio. Set to 0 if returning control is not desired. Possible values in seconds: 0 to 14400 seconds (4 hours) |
14400 |
Transitions:
These are the events that trigger transitions from this widget:
Name |
Key |
Description |
Return |
return |
Fired when the next TwiML fetch is received from Voice or Messaging for the current Execution |
Timeout |
timeout |
Fired when the timer is expired, and no new TwiML fetch is received for the current Execution |
Failed |
failed |
Fired when the URL is not successfully returned (or has an error) |
Need some help?
We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.