Menu

Expand
Rate this page:

TwiML Redirect

Not sure what TwiML is? Learn more about it here!

TwiML Redirect Widget.png

Description:

TwiML Redirect allows you to redirect a Voice Call to be handled outside of Studio and optionally return control back to Studio.

Note that your TwiML can be hosted and served in many ways, including and not limited to:

Passing Parameters to the TwiML Redirect URL

If you want to pass parameters to the TwiML Redirect URL 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.

Note: Studio does not actually make a request to this URL. Studio simply prints the TwiML, which instructs Twilio Voice or Messaging to make a new request to this URL.

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 controls is returned to Studio by Twilio Voice or Messaging with the FlowEvent=return parameter appended to the URL. Note: This is the only way Studio can regain control of a Voice call.

Timeout

timeout

Fired when the timer has expired and control has not passed back to Studio via the FlowEvent=return parameter. Note: Studio cannot regain control of a Voice call on Timeout.

Failed

failed

Fired if the URL is syntactically invalid at runtime. Note: This does not fire if the URL returns an error response (e.g. 404, 500) because Studio does not actually make a request to the Redirect URL.

Rate this page:

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 by visiting Twilio's Community Forums or browsing the Twilio tag on Stack Overflow.

        
        
        

        Thank you for your feedback!

        We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        Step 1

        Get link

        Get a free personal referral link here

        Step 2

        Give $10

        Your user signs up and upgrade using link

        Step 3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more