SUPPORT.TWILIO.COM END OF LIFE NOTICE: This site, support.twilio.com, is scheduled to go End of Life on February 27, 2024. All Twilio Support content has been migrated to help.twilio.com, where you can continue to find helpful Support articles, API docs, and Twilio blog content, and escalate your issues to our Support team. We encourage you to update your bookmarks and begin using the new site today for all your Twilio Support needs.

Can I Redirect an Active Call to a Twilio Studio Flow Using the REST API?

Question

Can I Redirect an Active Call to a Twilio Studio Flow Using the REST API?

 

Product

Twilio Studio

 

Answer

Twilio Studio is a powerful visual tool for building communication workflows, including voice call handling. A common question is whether you can redirect an active (in-progress) call to a Studio Flow using the REST API. This article explains the current capabilities and provides guidance on how to achieve similar outcomes.

Can I Redirect an Active Call to Studio?

No, you cannot redirect an active (already in-progress) call to a Twilio Studio Flow using the REST API.
Studio Flows can only be triggered for calls that are in the "ringing" state (i.e., before the call is answered). If you attempt to redirect an in-progress call to a Studio Flow endpoint, you will receive an HTTP 400 error.

Why Does This Happen?

  • For voice, Studio expects to be invoked at the start of a call (when the call is still ringing).
  • If you try to redirect an active call to Studio, Studio will attempt to join an existing execution. If it cannot find one, it returns a 400 error.

Workaround: Using Studio from the Start

If you want to use Studio to manage your call flow, the recommended approach is to initiate the call within Studio. This way, you can use Studio’s built-in widgets, including the TwiML Redirect widget, to control the call flow and even hand the call back to Studio as needed.

Example: Using the TwiML Redirect Widget

You can use the <Redirect> verb in your TwiML to send the call back to Studio at any point:

<Redirect>https://webhooks.twilio.com/v1/Accounts/ACXXXXXXXXXXXXXXXXXX/Flows/FWXXXXXXXXXXXXXX?FlowEvent=return&amp;foo=bar</Redirect>
  • Replace ACXXXXXXXXXXXXXXXXXX with your Account SID.
  • Replace FWXXXXXXXXXXXXXX with your Studio Flow SID.
  • You can add query parameters as needed.

For more details, see the Twilio Studio TwiML Redirect Widget documentation.

 

Additional Information 

Scenario Supported? Notes
Redirecting a ringing call to Studio Yes Studio can be triggered at the start of a call.
Redirecting an active/in-progress call No Will result in HTTP 400 error.
Using Studio to control call flow Yes Initiate the call in Studio and use TwiML Redirect as needed.

If you have further questions or need help designing your call flow, please reach out to Twilio Support or visit our Support Center or check the following documents:

 

Have more questions? Submit a request
Powered by Zendesk