Set up handoff destinations for your agent to route calls during conversations.
Use Call Handoffs to define destinations for customer-call routing. The typical use case for a handoff is a scenario where the agent cannot handle a query and a live, human agent is required.
To create a new handoff destination:
Go to the Call Handoffs section in the Build menu.
Click Add Handoff.
Fill in the following details:
Click Add to save the destination.
SIP headers can be used to send additional metadata when making a handoff. To add SIP headers:
Click Add SIP Header in the handoff setup modal.
Enter a Header Name (e.g., X-Customer-ID).
X-
prefix.Enter a Value (e.g., abc123
).
You can use $variables
in the SIP header values for dynamic data. Example:
X-Caller-ID: $caller_id
Repeat as needed for multiple headers.
SIP headers allow for custom integrations with external telephony systems and can help manage call behavior dynamically.
Once a handoff destination is created, it will appear in the list of destinations. You can edit, delete, or update the details as needed.
Handoff reason and utterance
The built-in handoff template and the conv.handoff()
helper now accept two optional, structured fields:
Field | Purpose | Example |
---|---|---|
reason | Machine-readable code explaining why the call is being escalated (e.g. policy_violation , needs_human , no_availability ). Surfaces in Conversation Review and the Conversations API. | policy_violation |
utterance | A short sentence the agent should speak before transfer begins. Logged alongside the handoff so QA can hear exactly what callers were told. | ”Let me transfer you to a specialist who can help.” |
Where it shows up
conv.handoff(reason="...", utterance="...")
to escalate programmatically.handoff
object for BI dashboards or CRM routing.Why it matters
If you’re bringing your own Twilio phone number to route calls, follow these steps to integrate it as a handoff destination:
Connect your Twilio account:
Assign a Twilio number:
Set up routing in Twilio:
https://your-polyai-instance-url/voice/call
Add the Twilio number as a handoff destination:
If you are using a US-based Twilio number, you must register for A2P 10DLC to comply with regulatory requirements. Twilio will block SMS messages if this is not completed.
transfer_call
functionThese two methods serve similar purposes — routing the user to another endpoint — but are mutually exclusive and differ in flexibility and implementation.
Feature | Call Handoff (UI-based) | transfer_call (code-based) |
---|---|---|
Ease of setup | UI form | — Requires Python editing |
Works in flow builder | ||
Works in Function Editor | — | |
Dynamic routing logic | — | Full control |
Supports custom metrics | — | |
Supports soft-handoff | — | |
Best for static SIP integration | — | |
Best for dynamic integrations | — | (e.g. Zendesk) |
These two methods cannot be used together in the same step. If you’re using transfer_call
in a function, it overrides any configured Call Handoff in the UI.
Use Call Handoff
if:
Use transfer_call
if:
Troubleshooting: If your messages fail to send, check the Twilio logs for these error codes:
Set up handoff destinations for your agent to route calls during conversations.
Use Call Handoffs to define destinations for customer-call routing. The typical use case for a handoff is a scenario where the agent cannot handle a query and a live, human agent is required.
To create a new handoff destination:
Go to the Call Handoffs section in the Build menu.
Click Add Handoff.
Fill in the following details:
Click Add to save the destination.
SIP headers can be used to send additional metadata when making a handoff. To add SIP headers:
Click Add SIP Header in the handoff setup modal.
Enter a Header Name (e.g., X-Customer-ID).
X-
prefix.Enter a Value (e.g., abc123
).
You can use $variables
in the SIP header values for dynamic data. Example:
X-Caller-ID: $caller_id
Repeat as needed for multiple headers.
SIP headers allow for custom integrations with external telephony systems and can help manage call behavior dynamically.
Once a handoff destination is created, it will appear in the list of destinations. You can edit, delete, or update the details as needed.
Handoff reason and utterance
The built-in handoff template and the conv.handoff()
helper now accept two optional, structured fields:
Field | Purpose | Example |
---|---|---|
reason | Machine-readable code explaining why the call is being escalated (e.g. policy_violation , needs_human , no_availability ). Surfaces in Conversation Review and the Conversations API. | policy_violation |
utterance | A short sentence the agent should speak before transfer begins. Logged alongside the handoff so QA can hear exactly what callers were told. | ”Let me transfer you to a specialist who can help.” |
Where it shows up
conv.handoff(reason="...", utterance="...")
to escalate programmatically.handoff
object for BI dashboards or CRM routing.Why it matters
If you’re bringing your own Twilio phone number to route calls, follow these steps to integrate it as a handoff destination:
Connect your Twilio account:
Assign a Twilio number:
Set up routing in Twilio:
https://your-polyai-instance-url/voice/call
Add the Twilio number as a handoff destination:
If you are using a US-based Twilio number, you must register for A2P 10DLC to comply with regulatory requirements. Twilio will block SMS messages if this is not completed.
transfer_call
functionThese two methods serve similar purposes — routing the user to another endpoint — but are mutually exclusive and differ in flexibility and implementation.
Feature | Call Handoff (UI-based) | transfer_call (code-based) |
---|---|---|
Ease of setup | UI form | — Requires Python editing |
Works in flow builder | ||
Works in Function Editor | — | |
Dynamic routing logic | — | Full control |
Supports custom metrics | — | |
Supports soft-handoff | — | |
Best for static SIP integration | — | |
Best for dynamic integrations | — | (e.g. Zendesk) |
These two methods cannot be used together in the same step. If you’re using transfer_call
in a function, it overrides any configured Call Handoff in the UI.
Use Call Handoff
if:
Use transfer_call
if:
Troubleshooting: If your messages fail to send, check the Twilio logs for these error codes: