Five9
Overview
Section titled “Overview”This guide explains how to integrate ElevenAgents with the Five9 Virtual Contact Center (VCC) using Five9 AI Agent Connect. Five9 transfers a live call to an ElevenLabs phone number, the ElevenLabs agent handles the conversation, and ElevenLabs returns routing or disposition data to Five9 so the Five9 flow can continue.
How the Five9 integration works
Section titled “How the Five9 integration works”Five9 AI Agent Connect uses an external transfer over SIP, with call context exchanged through custom SIP X- headers in both directions:
- Inbound transfer: The Five9 IVR External Transfer Module transfers the call to an ElevenLabs phone number, sending call context as SIP
X-headers on the INVITE. - Conversation: ElevenLabs answers the call and routes it to the correct agent, optionally through a router agent, then handles the conversation with the caller.
- Return path: When the conversation ends, ElevenLabs attaches routing and disposition data to the SIP BYE as
X-headers. - Post-AI routing: Five9 maps the returned headers into call variables and continues the call flow, such as transferring to a live agent, ending the call, or recording a disposition.
Requirements
Section titled “Requirements”Before setting up the Five9 integration, ensure you have:
- An active Five9 VCC domain with AI Agent Connect enabled.
- Administrator access to the Five9 configuration, or a Five9 implementation team to make the changes.
- An ElevenLabs account and an agent to handle the transferred calls.
- A SIP trunk phone number imported in ElevenLabs to use as the Five9 transfer destination.
ElevenLabs setup
Section titled “ElevenLabs setup”Import the transfer phone number
Section titled “Import the transfer phone number”Follow the SIP trunking guide to import the phone number Five9 will transfer calls to. Custom SIP headers and BYE headers require a SIP trunk phone number.
Import the number in E.164 format with a +1 country code (for example, +18005550100). Five9 sends the transfer in this format, and a mismatch will cause the transfer to fail.
Assign an agent
Section titled “Assign an agent”If a single agent handles all calls from Five9, assign it directly to the phone number in the Phone Numbers dashboard.
If multiple agents share one transfer number, assign a router agent instead and follow Routing multiple agents through one number.
Configure the returned headers
Section titled “Configure the returned headers”Map the dynamic variables your agent sets during the conversation to the SIP BYE header names Five9 expects. See Configuring BYE headers.
Run test calls
Section titled “Run test calls”Place test calls with Five9 and confirm the inbound headers arrive as dynamic variables and the BYE headers are returned as expected. Inbound header values are visible in the conversation history under the Phone Call tab.
Routing multiple agents through one number
Section titled “Routing multiple agents through one number”To route calls to several ElevenLabs agents through a single Five9 transfer number, assign a router agent to the phone number and have Five9 send the target agent in a header such as X-AgentID.
Inbound X- headers are exposed as dynamic variables, so X-AgentID is available to the router agent as {{sip_agentid}}. Configure the router agent with the agent transfer tool and add a transfer rule for each X-AgentID value you expect, mapping it to the agent that should take the call.
This avoids provisioning a separate phone number for every agent.
Headers sent from Five9 to ElevenLabs
Section titled “Headers sent from Five9 to ElevenLabs”Five9 can send call metadata as SIP X- headers on the INVITE. Header names are normalized by removing the X- prefix, converting to lowercase, replacing hyphens with underscores, and adding the sip_ prefix.
| Header | Dynamic variable | Description |
|---|---|---|
X-CallANI |
{{sip_callani}} |
The caller's phone number. |
X-CallDNIS |
{{sip_calldnis}} |
The dialed phone number. |
X-CallID |
{{sip_callid}} |
Unique Five9 call identifier. |
X-CallSessionID |
{{sip_callsessionid}} |
Identifier for the current session. |
X-CallCampaign |
{{sip_callcampaign}} |
Name of the Five9 campaign. |
X-AgentID |
{{sip_agentid}} |
Target ElevenLabs agent, used for routing via a router agent. |
Use these variables in agent prompts, first messages, and tools to personalize the conversation.
Headers returned from ElevenLabs to Five9
Section titled “Headers returned from ElevenLabs to Five9”ElevenLabs returns routing and reporting data on the SIP BYE. The following header names are the recommended convention for Five9 AI Agent Connect:
| Header | Description |
|---|---|
X-RouteType |
The action Five9 should take, for example SkillTransfer. |
X-RouteValue |
The target for the action, for example a Five9 skill name. |
X-RouteReason |
Context for the routing decision, such as the customer's intent. |
X-ConversationId |
The ElevenLabs conversation identifier, for log correlation. |
You can return any additional X- header your Five9 flow needs. Each header value comes from a dynamic variable on the agent, so the agent must set these variables during the conversation.
Configuring BYE headers
Section titled “Configuring BYE headers”BYE headers return the final values of the agent's dynamic variables to Five9. Map each dynamic variable name to a header name using attributes_to_headers on the phone number's inbound_trunk_config. Both variables your agent sets and system dynamic variables such as system__conversation_id can be mapped:
Python
import os
from dotenv import load_dotenv
from elevenlabs import ElevenLabs, InboundSipTrunkConfigRequestModel
load_dotenv()
elevenlabs = ElevenLabs(api_key=os.getenv("ELEVENLABS_API_KEY"))
elevenlabs.conversational_ai.phone_numbers.update(
phone_number_id="phnum_8901k4t9z5defmb8vh3e9361y7nj",
inbound_trunk_config=InboundSipTrunkConfigRequestModel(
attributes_to_headers={
"route_type": "X-RouteType",
"route_value": "X-RouteValue",
"route_reason": "X-RouteReason",
"system__conversation_id": "X-ConversationId",
}
),
)JavaScript
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
const elevenlabs = new ElevenLabsClient();
await elevenlabs.conversationalAi.phoneNumbers.update("phnum_8901k4t9z5defmb8vh3e9361y7nj", {
inboundTrunkConfig: {
attributesToHeaders: {
route_type: "X-RouteType",
route_value: "X-RouteValue",
route_reason: "X-RouteReason",
system__conversation_id: "X-ConversationId",
},
},
});cURL
curl -X PATCH "https://api.elevenlabs.io/v1/convai/phone-numbers/phnum_8901k4t9z5defmb8vh3e9361y7nj" \
-H "xi-api-key: $ELEVENLABS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"inbound_trunk_config": {
"attributes_to_headers": {
"route_type": "X-RouteType",
"route_value": "X-RouteValue",
"route_reason": "X-RouteReason",
"system__conversation_id": "X-ConversationId"
}
}
}'The header value is the dynamic variable's value at the end of the conversation, including values set during the call through agent tools or webhook overrides. A call that ends with the agent setting route_type to SkillTransfer and route_value to billing_support produces the following BYE headers:
X-RouteType: SkillTransfer
X-RouteValue: billing_support
X-RouteReason: Customer needs help with an invoice
X-ConversationId: conv_7401k6a2b8cxyzmn9pq3r5s7t1uvFive9 then routes the caller to the billing_support skill.
Recommended routing values
Section titled “Recommended routing values”Keep X-RouteType values simple and predictable so the Five9 flow can branch on them directly.
X-RouteType |
Example X-RouteValue |
Description |
|---|---|---|
SkillTransfer |
billing_support |
Transfer the call to a specific Five9 skill queue. |
PhoneTransfer |
+18005550199 |
Transfer the call to an external phone number. |
Hangup |
Empty | Terminate the call after the AI interaction. |
DispositionOnly |
Resolved |
End the call and record a specific disposition. |
Five9 setup
Section titled “Five9 setup”Your Five9 implementation team will typically:
- Enable AI Agent Connect for your Five9 domain.
- Configure the Five9 IVR transfer flow.
- Add the ElevenLabs phone number as the transfer destination.
- Configure the External Transfer Module.
- Configure the outbound
X-headers sent to ElevenLabs. - Configure the inbound
X-headers returned by ElevenLabs. - Map the returned headers into Five9 call variables.
- Configure the post-AI routing logic that branches on those variables.
- Test calls end to end.
Troubleshooting
Section titled “Troubleshooting”Transferred calls fail to connect
Section titled “Transferred calls fail to connect”- Confirm the ElevenLabs phone number is imported as a SIP trunk number and has an agent assigned.
- Verify the transfer destination configured in the Five9 External Transfer Module matches the imported number.
- Check that your firewall allows SIP signaling traffic on the configured transport and port, and that RTP ports are not blocked.
Inbound headers are not available as dynamic variables
Section titled “Inbound headers are not available as dynamic variables”- Confirm Five9 sends the headers with an
X-prefix on the INVITE. - Check the normalized variable name.
X-AgentIDbecomes{{sip_agentid}}, not{{X-AgentID}}or{{agent_id}}. - Inspect the conversation history under the Phone Call tab to see which headers arrived.
- Custom headers cannot override the
system__call_sidandsystem__caller_idsystem variables.
BYE headers are missing or empty
Section titled “BYE headers are missing or empty”- Verify
attributes_to_headersis set oninbound_trunk_configfor the phone number receiving the call. - Confirm the keys are dynamic variable names and the values are header names, not the reverse.
- Ensure the agent actually sets those dynamic variables during the conversation. An unset variable produces no header value.
Router agent transfers to the wrong agent
Section titled “Router agent transfers to the wrong agent”- Confirm Five9 sends
X-AgentIDon every transferred call. - Check that each
X-AgentIDvalue has a matching transfer rule on the router agent. - Verify the router agent's transfer rules reference
{{sip_agentid}}.