https://retellai.com/?utm_source=discord&utm_medium=seo logo
how can I use transfer agent to select an agent b...
# ❓・ai-evy-support
b
@AI Evy how can I use transfer agent to select an agent based on user language
a
Thanks for tagging me @BackSlash. I'll look through relevant sources and get back to you shortly.
### Answer You can use Agent Transfer to route callers to language-specific agents. This is explicitly mentioned as a use case: "Transferring from an agent speaking one language to another agent handling a different language, based on user preference." [(1) ]() [(2) ]() How to set it up: 1. Create separate agents for each language you want to support (e.g., English Agent, Spanish Agent) . 2. Add the Agent Transfer tool (for Single/Multi Prompt) or Agent Transfer Node (for Conversation Flow) . 3. Configure the transfer agent by selecting the ID and version of the language-specific agent to transfer to. 4. Update your prompt to instruct the agent when to trigger the transfer. For example: -
"If the user indicates they prefer to speak Spanish, use the agent_transfer tool to transfer to the Spanish Agent."
-
"At the start of the call, ask the user their preferred language. If they say Spanish, transfer to the Spanish Agent."
[(1) ]() Key benefits for language routing: - The transition is near-instant (lower latency than call transfer) [(1) ]() [(2) ]() - The destination agent has access to the full conversation history - No separate phone numbers needed for each language agent
​ To learn more, see the sources I considered: [[1] Agent Transfer](https://docs.retellai.com/build/single-multi-prompt/transfer-agent) [[2] Agent Transfer Node](https://docs.retellai.com/build/conversation-flow/transfer-agent-node) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
@AI Evy
a
Thanks for the follow-up, @BackSlash. I'll get back to you soon.
### Answer The Agent Transfer Node does exist in Conversation Flow. According to the documentation, you can find it by selecting "Agent Transfer" from the "Add New Node" menu. [(1) ]() It's also listed in the Node Overview under Call Control Nodes as the [Transfer Agent Node]() . [(2) ]() If you're not seeing it: 1. Make sure you're in the Conversation Flow editor (not Single/Multi Prompt mode) 2. Look in the left sidebar under the "Add New Node" options 3. It may be labeled as "Agent Transfer" or "Transfer Agent" Alternative if using Single/Multi Prompt: If you're using Single/Multi Prompt mode instead of Conversation Flow, you would add it as a tool rather than a node. Click "Add" in the tools section and select "Agent Transfer" from the dropdown menu. [(3) ]() Could you confirm which agent type you're using (Conversation Flow or Single/Multi Prompt) ? That will help narrow down where to find the transfer option.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
b
@AI Evy using custom LLM agents
a
Thanks for the follow-up, @BackSlash. I'll get back to you soon.
### Answer --- When using Custom LLM agents, the Agent Transfer functionality works differently than with Retell's built-in Response Engine. With Custom LLM, you control the agent's behavior through your own WebSocket server. [(1) ]() To implement language-based agent selection, you would need to handle this logic within your custom LLM backend: 1. Detect the user's language preference from the transcript sent to your server via the
transcript
field in the WebSocket events 2. Implement transfer logic in your response - Your custom LLM can send a response with
end_call: true
and handle the routing logic on your backend, or you can use the Register Phone Call API to initiate a new call to a different agent [(2) ]() 3. Use
agent_override
when registering calls - You can dynamically select which agent configuration to use at call registration time The Custom LLM WebSocket gives you full control over what the agent says and actions like ending the call. [(1) ]() However, the built-in Agent Transfer Node/Tool available in Conversation Flow and Single/Multi Prompt modes may not be directly accessible when using a fully custom LLM setup. Alternative approach: Consider using Retell's Response Engine with Custom LLM integration for specific tasks while keeping the built-in transfer capabilities. [(3) ]() Check out these potentially useful sources: - [Integrate LLM]() - [LLM WebSocket]() - [Register Phone Call]() Would you like a ge
neral answer on how to architect language-based routing with Custom LLM?
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
​ To learn more, see the sources I considered: [[1] LLM WebSocket](https://docs.retellai.com/api-references/llm-websocket) [[2] Register Phone Call](https://docs.retellai.com/api-references/register-phone-call) [[3] Inside Retell AI | The Conversational AI Platform Behind Scalable AI Phone Systems | Retell AI](https://www.retellai.com/blog/inside-retell-ai-conversational-ai-phone-system) ​
b
@AI Evy having issues connecting Twilio to my websocket server and Retell call disconnects right away Retell when tested in the agent screen communicates fine with my server
a
Thanks for the follow-up, @BackSlash. I'll get back to you soon.
### Answer Since calls work fine from the Retell dashboard but disconnect immediately with Twilio, here are some things to check: 1. Check the disconnection reason Use the [Get Call API]() or dashboard to see the
disconnection_reason
. Common error reasons include: [(1) ]() -
error_llm_websocket_open
- LLM websocket did not open between Retell server and your backend -
error_llm_websocket_lost_connection
- LLM websocket connection broke during the call -
error_no_audio_received
- Has not received audio from Twilio for a while after connection has established -
registered_call_timeout
- Phone call is 30s or more apart from registration 2. Verify your WebSocket URL protocol [(2) ]() - For HTTPS endpoints, use
wss://
prefix - For HTTP endpoints, use
ws://
prefix 3. Check for trailing slash issues - Correct: ` - Incorrect (sometimes) : ` 4. Add logging to your server - Add logging in your websocket code to see if the websocket is connected - Add logging in your websocket message code to check if you receive messages from Retell server - Check if you're accidentally sending
end_call=true
at any point 5. Verify your server supports WebSocket Some server setups don't support WebSocket (e.g., Vercel edge functions and serverless functions cannot act as a websocket server) . 6. Check for timeout issues Some server vendors automatically timeout connections (e.g., Replit non-reserved instances timeout at 5min) . Can you share what
disconnection_reason
you're seeing in the call details?
​ To learn more, see the sources I considered: [[1] Debug call disconnection](https://docs.retellai.com/reliability/debug-call-disconnect) [[2] Troubleshooting Guide](https://docs.retellai.com/integrate-llm/troubleshooting) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
b
call history does not show the call at all
@AI Evy
a
Thanks for the follow-up, @BackSlash. I'll get back to you soon.
### Answer --- If the call isn't showing in your Retell call history at all, the issue is likely happening before Retell is involved—meaning the call registration step may not be completing successfully. For Custom Telephony (like Twilio) , you must register the call with Retell first: When using your own Twilio setup with a custom LLM, you need to use the Register Phone Call API to register the call before connecting audio. [(1) ]()
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneCallResponse = await client.call.registerPhoneCall({
  agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
}) ;
console.log(phoneCallResponse.agent_id) ;
Key things to verify: 1. Is your server calling the Register Phone Call API? If this step fails or isn't happening, Retell won't know about the call and it won't appear in history. 2. Check the
registered_call_timeout
issue
- Phone calls must connect within 30 seconds of registration, otherwise they timeout. 3. Whitelist Retell's IP - For incoming requests, only allow Retell IP address:
100.20.5.228
[(2) ]() 4. Verify your WebSocket endpoint - Your server should have a websocket endpoint at
{your-server-websocket-endpoint}/{call_id}
that Retell connects to. [(3) ]() Troubleshooting steps: - Add logging to confirm the Register Phone Call API is being called and returning successfully - Check if you're receiving the
call_id
back from registration - Verify your Twilio webhook is correctly triggering your backend to register the call with Retell Can you confirm whether your backend is successfully calling the Register Phone Call API when Twilio receives the inbound call?
​ To learn more, see the sources I considered: [[1] Register Phone Call](https://docs.retellai.com/api-references/register-phone-call) [[2] Setup WebSocket Server](https://docs.retellai.com/integrate-llm/setup-websocket-server) [[3] LLM WebSocket](https://docs.retellai.com/api-references/llm-websocket) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
b
What Actually Happened ✅ User calls Twilio ✅ IVR menu plays ✅ Digit detected, language selected ✅ registerPhoneCall succeeds → returns call_id ✅ TwiML sent to Twilio ✅ Twilio reports "stream-started" ❌ Stream disconnects 0.2 seconds later ("stream-stopped") ❌ Retell NEVER connects to our /llm-websocket endpoint ❌ No WebSocket upgrade request received The Core Problem Retell failed to connect to our Custom LLM WebSocket, causing it to reject the audio stream from Twilio. Suspected Root Causes Agent configuration mismatch - Custom LLM URL in Retell Dashboard was stale/incorrect Dynamic Cloudflare URLs - Tunnel URL changed between restarts Timing issue - Retell tried to connect before agent was fully published Unknown Retell limitation - Platform might not support this flow reliably Why We Moved to SIP Direct SIP routing bypasses our server entirely: Twilio → Retell (SIP, one agent only) → Our Server (WebSocket only) This works reliably but limits us to 1 agent = 1 Retell number.
@AI Evy
a
Thanks for the follow-up, @BackSlash. I'll get back to you soon.
### Answer ### Answer Based on your description, the issue is that Retell never connects to your Custom LLM WebSocket endpoint after you register the call. This is a known challenge when combining custom telephony (Twilio) with Custom LLM. Key points about the Custom LLM WebSocket flow: The WebSocket endpoint should be configured as
{your-server-websocket-endpoint}/{call_id}
- Retell initiates this connection when starting the call. [(1) ]() Potential causes for your scenario: 1. Custom LLM URL configuration - The Custom LLM WebSocket URL in your Retell agent configuration must be accessible and correctly pointing to your server. If using dynamic URLs (like ngrok or Cloudflare tunnels) , the URL must be updated in the agent settings each time it changes. [(2) ]() 2. Timing between registration and connection - The
registered_call_timeout
error occurs when the phone call is 30 seconds or more apart from registration. [(1) ]() 3. Transport/SIP configuration - For custom telephony, Retell's SIP server is
sip:sip.retellai.com
with IP block
18.98.16.120/30
for whitelisting. [(3) ]() Why SIP works but the Dial-to-SIP + Custom LLM flow doesn't: With Elastic SIP Trunking, Retell handles the telephony layer directly. When using Dial-to-SIP with Custom LLM, your server must handle both the telephony webhook AND the LLM WebSocket connection - and Retell must successfully connect to your WebSocket endpoint before audio flows. Possible workaround: If you need multiple language agents with one number using SIP, consider using
override_agent_id
when creating/registering calls to dynamically select the agent
based on detected language. [(4) ]() [(5) ]() Check out these potentially useful sources: - [Custom Telephony Overview]() - [LLM WebSocket]() - [Register Phone Call]() For further assistance with this specific configuration, you may want to reach out via [Contact Sales]() or check [) .
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
b
@AI Evy With SIP headers? ❓ Can we pass agent override via SIP header? Would look like: sip:user@retell.com?override_agent_id=xxx This would NOT put us in the middle But I'm not sure if Retell supports this
a
Thanks for the follow-up, @BackSlash. I'll get back to you soon.
### Answer Based on the available documentation, I don't see explicit support for passing
override_agent_id
via SIP URI parameters in the format you described (
sip:user@retell.com?override_agent_id=xxx
) . What IS supported: For inbound calls, you can use the Inbound Webhook to dynamically override the agent. When Retell receives an inbound call, it sends a request to your webhook, and you can respond with override parameters including
override_agent_id
. [(1) ]()
Copy code
json
{
  "call_inbound": {
    "override_agent_id": "agent_12345",
    "override_agent_version": 1,
You can also add custom SIP headers to transfers, but all header names must start with
X-
. [(2) ]() For your language-routing use case: The recommended approach appears to be using the inbound webhook. When Retell receives the SIP call, your webhook can inspect the call details and return the appropriate
override_agent_id
based on your IVR selection logic. [(1) ]() This does require your server to be "in the middle" for the webhook response, but it's a lightweight HTTP request/response—not a persistent WebSocket connection. Check out these potentially useful sources: - [Inbound webhook]() - [Create Phone Call]() For confirmation on SIP URI parameter support specifically, you may want to reach out via [Contact Sales]() or check [) .
​ To learn more, see the sources I considered: [[1] Inbound webhook](https://docs.retellai.com/features/inbound-call-webhook) [[2] Call Transfer Node](https://docs.retellai.com/build/conversation-flow/call-transfer-node) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.