Flex uses Twilio Studio to implement pre-agent workflows. Refer to the Core Concepts: Studio chapter for a general introduction.
The Studio Flow is executed when one of the Trigger events happens. For Flex, the most relevant triggers are Incoming Message, Incoming Call and Incoming Conversation.
To configure a Phone Number to trigger your desired Studio Flow, head to Phone Numbers > Manage > Active numbers, choose the respective number, and set the Voice or Messaging trigger to call the respective Studio Flow.
You can use the Search for a Profile Studio widget for personalized pre-agent handling and routing. The Search for a Profile widget uses Unified Profiles capabilities to provide you with real-time profile data for each customer that calls or messages your business.
With the Search for a Profile widget, you can look up customer profiles in Twilio Segment by identifier attribute, such as phone number or email address. If a profile is found, the widget returns the profile SID and all the mapped traits for that profile, including custom and computed traits.
This contextual data provides a better understanding of each customer, which enables Flex to use your preferred pre-agent handling or direct the customer to the most relevant TaskRouter workflow for personalized routing.
Intelligent routing enables use cases that include:
The Send to Flex widget will create a TaskRouter Task for the incoming communication, and execute a TaskRouter Workflow to route it to an agent.
For the Incoming Call trigger, Send to Flex will enqueue the Voice and the caller will hear hold music while waiting for an agent to respond.
In Flex Conversations (which requires Flex UI 2.0), a new Trigger Incoming Conversation has been added. In this case, Send to Flex will create a new Interaction using the /Interactions endpoint, which then creates a new Task for assignment to a Worker.
Optionally, you can declare Task attributes, priority, timeout, and a hold music TwiML URL. To learn more, see Send to Flex.
Use Studio Flows to build out any logic that needs to execute before a Task is created and routed to an agent. Typical use cases include IVR, chat bots, and call deflection. Some useful resources include:
The Studio REST API v2 allows you to programmatically create, publish, and manage your Studio Flows without having to log in to the Twilio Console. Studio Flows are defined using a JSON schema to configure the widgets and the functionality. The REST API also provides methods to trigger an outbound call or message, as well as for reporting on Executions that have completed.