Objective
This article explains how to route a Flex voice call to a Twilio Studio Flow after a Flex task is completed. Many users want to trigger post-call automation, surveys, or other workflows in Studio after an agent finishes a Flex voice task. This guide covers the recommended approaches, limitations, and workarounds for achieving this with Flex, Studio, and Programmable Voice.
Product
Flex, Studio
Environment
Twilio Console
User Account Permission/Role(s) Required
- Access to Flex and Studio configuration in the Twilio Console
- Ability to create and manage TwiML Bins, Functions, or Studio Flows
- API credentials for programmatic call handling (if needed)
Procedure
-
End the Original Flex Conference
- After the Flex task is completed, ensure the original conference is ended and the customer’s call leg is disconnected. Studio Flows cannot accept a live call leg from an in-progress conference.
-
Initiate a New Call to Trigger Studio
- Programmatically place a new outbound call to the customer’s number from a Twilio number configured to trigger your Studio Flow for inbound calls.
- Set the call’s URL to your Studio Flow’s webhook, or to a TwiML Bin/Function that redirects to the Studio Flow.
-
Passing Context Between Calls
- Any context from the original call (such as Task attributes or Flex context) does not automatically transfer to the new call leg. You’ll need to handle context passing explicitly.
-
If you need to pass context (such as task attributes) from the original call to the new Studio Flow, consider:
- Using Twilio Sync to store context keyed by the call SID.
- Passing query parameters in the new call’s URL.
- For anonymized callers, context passing may require creative solutions, such as using the call SID as a key.
-
Advanced Option: In-Progress Call Trigger
- You may attempt to trigger a Studio Flow for an in-progress call by adding the query parameter Trigger=inProgressCall to your Studio webhook URL.
- Example TwiML:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Redirect>https://webhooks.twilio.com/v1/Accounts/ACxxxxxxxxxx/Flows/FWxxxxxxxxxxx?Trigger=inProgressCall</Redirect>
</Response>- Important Limitation: Voice Status Callback events (including Hangup) are not sent to the Studio execution in this scenario. This may result in stuck executions, so you must implement and run a timely process to regularly stop or clean up old ongoing executions.
Additional Information
For more information, please refer:
- Can I Redirect an Active Call to a Twilio Studio Flow Using the REST API?
- How to Pass Call Context When Forwarding Across the PSTN
- Error 13201: Cannot Dial out from a Dial Call Segment
Need help with custom implementation?
If you require hands-on assistance with designing or building a custom solution for your workflow, consider engaging Twilio Professional Services. Our experts can help you architect, implement, and optimize advanced integrations tailored to your needs.