Trying to set up your project telephony using Twilio? Start with the telephony guide for an
overview of connecting Twilio telephony to your PolyAI projects using the 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.
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.
Install Twilio addon
After obtaining the Connector Token, install the PolyAI Connector Addon in Twilio:- Log in to your Twilio account.
- Go 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.