Twilio
Integrate PolyAI voice agents into your Twilio routing and handoff setups.
The PolyAI integration for Twilio Flex for contact centers routes incoming customer calls to PolyA’s voice agents using the Twilio telephony system, and then manages handoff if they need to be handed on to a live agent.
If handoff is needed, the integration transfers the call and accompanying data to Twilio Flex for human handling. All interactions are managed through SIP or a no-code Twilio Studio workflow, and are logged in the Twilio UI.
Set up connector
Create a PolyAI Connector and retrieve your Connector Token using the API.
Install Twilio addon
Link your PolyAI Connector Token to Twilio.
Configure routing
Use TwiML or Twilio Studio to route calls to PolyAI.
Handle handoffs
Manage live-agent handoffs with the PolyAI Handoff API.
PolyAI is live on the Twilio Marketplace and uses a media stream connector implementation.
Overview of capabilities
- Automated call handling: Twilio routes incoming calls to PolyAI virtual agents, where customer queries are resolved, or additional data is captured for live-agent handoffs.
- Live-agent handoffs: The PolyAI virtual agent passes contextual data from PolyAI to Twilio Flex, to be displayed in the Flex UI.
- Routing: Supports Twilio Studio flows and programmable routing using TwiML syntax.
Set up connector
To integrate PolyAI with Twilio, start by creating a PolyAI Connector. The connector links Twilio with your PolyAI project configuration.
Command to create connector
Outputs
The command generates:
- Connector ID: Used for debugging configurations.
- Connector Token: Required for linking the PolyAI Connector in Twilio.
Mapping notes
Each Twilio Connector maps directly to:
- A PolyAI Connector.
- A PolyAI project configuration.
To manage multiple environments (e.g., Sandbox and Production), repeat the above steps to create separate connectors for each.
Install Twilio addon
After obtaining the Connector Token, install the PolyAI Connector Addon in Twilio:
- Log in to your Twilio account.
- Navigate to the Twilio Marketplace and search for “PolyAI Connector.”
- Install the addon and paste your Connector Token into the required field.
- Save changes and verify the connection.
Configure routing
Twilio offers two routing methods: TwiML and Twilio Studio.
TwiML syntax
Define your Twilio flow with the <Connect>
tag:
Twilio Studio flow
- Open Twilio Studio.
- Add a Make HTTP Request widget to retrieve PolyAI handoff context using an API.
- Use a Send To Flex widget to route calls to agents with the retrieved context.
- Save and test the flow.
Handle handoffs
PolyAI provides detailed call context for live-agent handoffs:
- Store handoff data: PolyAI captures customer information in the
context.state.handoff
object. - API retrieval: Twilio Functions fetch this data using the PolyAI Handoff API.
- Flex display: The data is passed to Twilio Flex, where live agents can view it in the Flex UI.