https://retellai.com/?utm_source=discord&utm_medium=seo logo
How do I trigger a function (like transfer_call or...
# ❓・ai-evy-support
a
@AI Evy How do I trigger a function (like transfer_call or say_message) for a live call via API?”
a
Thanks for tagging me @axe9467. I'll look through relevant sources and get back to you shortly.
### Answer You can trigger functions like transfer_call during a live call through the LLM WebSocket interface [(1) ]() . There are several ways to do this: ## Using Response Events You can trigger a transfer by setting the
transfer_number
field in a response event :
Copy code
json
{
  "response_type": "response",
  "response_id": 1,
  "content": "I'll transfer you to our support team now.",
  "content_complete": true,
  "transfer_number": "+1234567890"
}
## Using Agent Interrupt Events For immediate function execution, use an agent interrupt event :
Copy code
json
{
  "response_type": "agent_interrupt",
  "interrupt_id": 1,
  "content": "Transferring you now.",
  "content_complete": true,
  "transfer_number": "+1234567890"
}
## Key Points - The transfer will execute after the associated content is fully spoken - For Retell numbers or imported numbers, the transfer happens automatically - If using custom telephony via SIP endpoint, you need to implement your own transfer logic - You can also use
end_call
field to end calls or
digit_to_press
for DTMF tones The WebSocket connection receives live transcript updates and expects your server to respond with these structured events to control the agent's behavior .
​ To learn more, see the sources I considered: [[1] 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.
a
@AI Evy I am building a call screening system where my backend needs to instruct the AI agent mid-call based on my SMS reply (e.g., transfer the call, say a custom message, or end the call). I understand from your documentation that live call control is handled via the LLM WebSocket interface. Could you please provide: The exact process and WebSocket URL format for connecting to a live call session for a specific agent/call. How to obtain the correct WebSocket URL and call/session ID for each incoming call (is this provided via webhook, API, or another method?). The required authentication and message format for sending events like: Transfer the call to a specific number Say a custom message to the caller End the call Any example code or documentation for sending these control events from a backend service. My goal: When I reply to the screening SMS, my backend should be able to send a WebSocket event to the live call session to trigger a transfer, say a message, or end the call, without manual intervention. Thank you!
a
Thanks for the follow-up, @axe9467. I'll get back to you soon.
### Answer ## WebSocket URL Format and Connection Process The LLM WebSocket endpoint format is:
{your-server-websocket-endpoint}/{call_id}
[(1) ]() . Retell AI initiates the WebSocket connection to your server when starting a call . ## Setting Up Your WebSocket Server Your server needs to handle incoming WebSocket connections from Retell. Here's the basic setup structure:
Copy code
javascript
import { RawData, WebSocket } from "ws";
import { Request } from "express";
var express = require('express') ;
var app = express() ;
var expressWs = require('express-ws') (app) ;
const port = 3000

app.ws("/llm-websocket/:call_id",
 async (ws: WebSocket, req: Request) => {
 const callId = req.params.call_id;
 
 ws.on("error", (err) => {
 console.error("Error received in LLM websocket client: ", err) ;
 }) ;
 ws.on("message", async (data: RawData, isBinary: boolean) => {
 console.log(data) ;
 }) ;
 },
) ;
[(2) ]() ## Obtaining Call Information When a call starts, you can get the call details through: - The
call_id
parameter in your WebSocket endpoint [(1) ]() - Setting
call_details
to true in the config event to receive call information immediately - Using the Get Call API with the call_id to retrieve call information [(3) ]() ## Authentication and Message Formats ### For Transfers To transfer a call, send a response event with the
transfer_number
field [(1) ]() :
Copy code
json
{
  "response_type": "response",
  "response_id": 1,
  "content": "I'll transfer you now.",
  "content_complete": true,
  "transfer_number": "+1234567890"
}
### For Custom Messages Send a response event with your custom content :
Copy code
json
{
  "response_type": "response", 
  "response_id": 1,
  "content": "Your custom message here",
  "content_complete": true
}
### For Ending Calls Use the
end_call
field in your response :
Copy code
json
{
  "response_type": "response",
  "response_id": 1, 
  "content": "Goodbye",
  "content_complete": true,
  "end_call": true
}
### For Immediate Actions Use agent interrupt events for immediate execution :
Copy code
json
{
  "response_type": "agent_interrupt",
  "interrupt_id": 1,
  "content": "Transferring you now.",
  "content_complete": true,
  "transfer_number": "+1234567890"
}
## Key Implementation Notes - Your server must send the first message when the WebSocket connection is established - Retell restricts incoming requests to allowlisted IP addresses:
100.20.5.228
[(2) ]() - The WebSocket uses text messages where the data attribute is a JSON object stringified [(1) ]() - Check the
interaction_type
field to determine when responses are required ## Example Demo Repositories For complete implementation examples, check these repositories [(4) ]() : - [Node Demo Repository]() - [Python Demo Repository]()
​ To learn more, see the sources I considered: [[1] LLM WebSocket](https://docs.retellai.com/api-references/llm-websocket) [[2] Setup WebSocket Server](https://docs.retellai.com/integrate-llm/setup-websocket-server) [[3] Get Call](https://docs.retellai.com/api-references/get-call) [[4] Custom LLM Overview](https://docs.retellai.com/integrate-llm/overview) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
@AI Evy “How do I set my LLM WebSocket endpoint for live call control? My backend is at wss://screener-uu36.onrender.com/llm-websocket.”
a
Thanks for the follow-up, @axe9467. I'll get back to you soon.
### Answer To set your LLM WebSocket endpoint for live call control, you need to configure it through the Retell AI dashboard or API when creating or updating your agent [(1) ]() . ## Setting the WebSocket URL Your WebSocket endpoint should be configured as:
wss://screener-uu36.onrender.com/llm-websocket
. When Retell AI initiates a call, it will connect to your endpoint using the format:
{your-server-websocket-endpoint}/{call_id}
. ## WebSocket Server Setup Your server needs to handle the incoming WebSocket connections from Retell. Here's the basic structure you need [(2) ]() :
Copy code
javascript
import { RawData, WebSocket } from "ws";
import { Request } from "express";
var express = require('express') ;
var app = express() ;
var expressWs = require('express-ws') (app) ;
const port = 3000

app.ws("/llm-websocket/:call_id",
 async (ws: WebSocket, req: Request) => {
 const callId = req.params.call_id;
 
 ws.on("error", (err) => {
 console.error("Error received in LLM websocket client: ", err) ;
 }) ;
 ws.on("message", async (data: RawData, isBinary: boolean) => {
 console.log(data) ;
 }) ;
 },
) ;
## Important Configuration Notes - Your server must send the first message when the WebSocket connection is established [(1) ]() - Retell restricts incoming requests to allowlisted IP addresses:
100.20.5.228
[(2) ]() - The WebSocket uses text messages where the data attribute is a JSON object stringified [(1) ]() ## Testing Your Endpoint You can test your WebSocket connection using Postman [(3) ]() : 1. Create a new WebSocket request 2. Enter your WebSocket URL and click "Connect" 3. Send a "Hello" message to verify the connection works Make sure your endpoint protocol matches your connection type - use
wss://
for HTTPS endpoints and
ws://
for HTTP endpoints .
​ To learn more, see the sources I considered: [[1] LLM WebSocket](https://docs.retellai.com/api-references/llm-websocket) [[2] Setup WebSocket Server](https://docs.retellai.com/integrate-llm/setup-websocket-server) [[3] 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.
a
@AI Evy Where can I find: The LLM WebSocket endpoint is a separate setting and is typically not found in the same place as the HTTP webhook. It is often: In the agent’s advanced or integration settings, Labeled as “LLM WebSocket Endpoint,” “Function WebSocket Endpoint,” “Live Call WebSocket,” or similar, Or, in some platforms, only configurable via the API or by contacting support. What to Look For Not the “Agent Level Webhook URL” (that’s for HTTP POST events). Look for a field or section mentioning: “WebSocket” “LLM WebSocket” “Function Calling WebSocket” “Live Call Control Endpoint” It may be under “Advanced Settings,” “Integrations,” or “Developer Settings.”
a
Thanks for the follow-up, @axe9467. I'll get back to you soon.
### Answer Based on the Retell AI documentation, the LLM WebSocket endpoint is configured when creating agents via API using the
llm_websocket_url
parameter [(1) ]() . ## API Configuration When creating agents through the API, you must specify the
llm_websocket_url
parameter . The endpoint format follows:
{your-server-websocket-endpoint}/{call_id}
[(2) ]() . ## Dashboard vs API Configuration The documentation indicates that when creating agents from the UI dashboard, you don't need to specify the WebSocket URL as agents use internal endpoints like
"wss://api.retellai.com/retell-llm-new/..."
[(1) ]() . However, when creating agents via API, the
llm_websocket_url
parameter is required . ## For Retell LLM Users If you're using Retell's built-in LLM rather than a custom LLM, you need to first call the ` API to get the LLM websocket URL, then use that URL when creating the agent . This creates a composable system where LLMs and agents are separate blocks that can be attached together . ## Important Note The recent changelog mentions that
llm_websocket_url
is now deprecated in favor of a new
response_engine
field [(3) ]() . This suggests the configuration method may be changing in newer versions. The documentation doesn't specify a particular dashboard location for this setting, but indicates it's primarily configured through API calls for custom LLM integrations.
​ To learn more, see the sources I considered: [[1] Create agent via API, llm_websocket_url required](https://discord.com/channels/1186424376300679209/1247914407909130241) [[2] LLM WebSocket](https://docs.retellai.com/api-references/llm-websocket) [[3] Platform Changelogs | Retell AI](https://www.retellai.com/changelog) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
@AI Evy Where can I setup my LLM WebSocket endpoint
a
Thanks for the follow-up, @axe9467. I'll get back to you soon.
## Configuration Process 1. Set up your WebSocket server at your desired endpoint (like
wss://screener-uu36.onrender.com/llm-websocket
) 2. Configure the endpoint when creating your agent through the Retell AI API or dashboard [(2) ]() 3. Ensure proper security - Retell restricts incoming requests to allowlisted IP addresses:
100.20.5.228
[(1) ]() ## Important Notes - Your server must send the first message when the WebSocket connection is established [(2) ]() - The WebSocket uses text messages where the data attribute is a JSON object stringified - Retell AI will initiate the WebSocket connection to your server when starting a call The documentation focuses on the server-side setup rather than a specific dashboard location for configuring the WebSocket URL. You'll need to provide your WebSocket endpoint URL when setting up your agent configuration.
### Answer Based on the available documentation, the LLM WebSocket endpoint configuration is handled through your server setup rather than through a specific dashboard setting [(1) ]() [(2) ]() . ## Setting Up Your WebSocket Endpoint You need to create a WebSocket server that Retell AI can connect to. The endpoint format is:
{your-server-websocket-endpoint}/{call_id}
[(2) ]() . Here's how to set up your WebSocket server [(1) ]() :
Copy code
javascript
import { RawData, WebSocket } from "ws";
import { Request } from "express";
var express = require('express') ;
var app = express() ;
var expressWs = require('express-ws') (app) ;
const port = 3000

// Your other API endpoints
app.get('/', (req, res) => {
 res.send('Hello World!')
})

app.ws("/llm-websocket/:call_id",
 async (ws: WebSocket, req: Request) => {
 // callId is a unique identifier of a call, containing all information about it
 const callId = req.params.call_id;
 // You need to send the first message here, but for now let's skip that.
 ws.on("error", (err) => {
 console.error("Error received in LLM websocket client: ", err) ;
 }) ;
 ws.on("message", async (data: RawData, isBinary: boolean) => {
 // Retell server will send transcript from caller along with other information
 // You will be adding code to process and respond here
 console.log(data) ;
 }) ;
 },
) ;

app.listen(port, () => {
 console.log(`Example app listening on port ${port}`)
}) ;
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] Setup WebSocket Server](https://docs.retellai.com/integrate-llm/setup-websocket-server) [[2] LLM WebSocket](https://docs.retellai.com/api-references/llm-websocket) ​
a
@AI Evy I am building a real-time call screening system and need to programmatically control live calls (e.g., transfer, say a message, end call) based on user input received via SMS. I understand from your documentation and support that this requires the LLM WebSocket interface, where Retell connects to my backend at a URL like: websocket However, I do not see any option in the dashboard or agent configuration to set the LLM WebSocket endpoint for my agent. Could you please: Enable the LLM WebSocket endpoint setting for my account/agent, or Set my agent’s LLM WebSocket endpoint to wss://screener-uu36.onrender.com/llm-websocket on your end, or Provide the exact API call or process to set this endpoint for live call control. This is critical for my use case, as I need to send real-time instructions to the AI agent during active calls. If there are any prerequisites or additional steps required, please let me know. Thank you very much for your help!
a
Thanks for the follow-up, @axe9467. I'll get back to you soon.
### Answer ### Answer Based on the documentation, the LLM WebSocket endpoint must be configured when creating your agent, as it's a required parameter for custom LLM integrations [(1) ]() . Here's how to set this up: ## Creating Agent with Custom LLM WebSocket When creating agents via API, you must specify the
llm_websocket_url
parameter . The endpoint ` requires the "llm_websocket_url" parameter value . ## For Retell LLM Users If you're using Retell's built-in LLM rather than a custom LLM, you need to first call the ` API to get the LLM websocket URL, then use that URL when creating the agent . This creates a composable system where LLMs and agents are separate blocks that can be attached together . ## WebSocket Server Requirements Your WebSocket server at
wss://screener-uu36.onrender.com/llm-websocket
needs to handle the connection properly [(2) ]() . Here's the basic structure:
Copy code
javascript
import { RawData, WebSocket } from "ws";
import { Request } from "express";
var express = require('express') ;
var app = express() ;
var expressWs = require('express-ws') (app) ;
const port = 3000

app.ws("/llm-websocket/:call_id",
 async (ws: WebSocket, req: Request) => {
 const callId = req.params.call_id;
 
 ws.on("error", (err) => {
 console.error("Error received in LLM websocket client: ", err) ;
 }) ;
 ws.on("message", async (data: RawData, isBinary: boolean) => {
 console.log(data) ;
 }) ;
 },
) ;
## Important Configuration Notes - Your server must send the first message when the WebSocket connection is established [(3) ]() - Retell restricts incoming requests to allowlisted IP addresses:
100.20.5.228
[(2) ]() - The WebSocket endpoint format is:
{your-server-websocket-endpoint}/{call_id}
[(3) ]() - When you create agents and LLMs via APIs, they are like composable blocks, so you can create them separately and attach the LLM websocket url to an agent [(1) ]() ## Dashboard vs API Difference When you create agents from the UI dashboard, you don't have to specify the WebSocket URL as agents use internal endpoints like "wss://api.retellai.com/retell-llm-new/..." . However, for custom LLM integrations via API, the
llm_websocket_url
parameter is required . For your specific use case, you'll need to create your agent via the API with your WebSocket endpoint specified in the
llm_websocket_url
parameter.
​ To learn more, see the sources I considered: [[1] Create agent via API, llm_websocket_url required](https://discord.com/channels/1186424376300679209/1247914407909130241) [[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.
a
@AI Evy What is Retell's response_engine and voice_id values.
a
Thanks for the follow-up, @axe9467. I'll get back to you soon.
### Answer ### Answer ## Response Engine The
response_engine
is an object that specifies the LLM engine to use for generating agent responses [(1) ]() . It has several options: For Retell LLM (Option 1) , the structure is :
Copy code
json
{
  "type": "retell-llm",
  "llm_id": "llm_234sdertfsdsfsdf",
  "version": 0
}
The
response_engine
object contains : - `type`: Must be
"retell-llm"
for Retell's built-in LLM - `llm_id`: The ID of the Retell LLM Response Engine - `version`: Version of the Retell LLM Response Engine (can be
null
) ## Voice ID Values The
voice_id
is a string that specifies the unique voice used for the agent . You can find the list of available voices and their previews in the Dashboard . Example voice IDs from the documentation include [(2) ]() : -
"11labs-Adrian"
-
"openai-Alloy"
-
"deepgram-Angus"
## Voice Model Options For ElevenLabs voices, you can optionally set the
voice_model
parameter [(1) ]() . Available options include : -
"eleven_turbo_v2"
-
"eleven_flash_v2"
-
"eleven_turbo_v2_5"
-
"eleven_flash_v2_5"
-
"eleven_multilingual_v2"
-
"tts-1"
-
"gpt-4o-mini-tts"
## Example Agent Creation Here's an example of creating an agent with these values [(2) ]() :
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const agentResponse = await client.agent.create({
 response_engine: { llm_id: 'llm_234sdertfsdsfsdf', type: 'retell-llm' },
 voice_id: '11labs-Adrian',
}) ;
console.log(agentResponse.agent_id) ;
​ To learn more, see the sources I considered: [[1] Create Agent](https://docs.retellai.com/api-references/create-agent) [[2] Create Agent](https://docs.retellai.com/api-references/create-agent) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
@AI Evy My backend needs the real call/session ID in the send_info function payload so I can match it to the live WebSocket connection for in-call control. How do I ensure the LLM passes the correct call ID, not a placeholder?”
a
Thanks for the follow-up, @axe9467. I'll get back to you soon.
### Answer ### Answer ## Getting the Real Call ID in Your WebSocket Handler The real call ID is automatically provided to your WebSocket endpoint as a path parameter [(1) ]() . When Retell AI connects to your server, it uses the format
{your-server-websocket-endpoint}/{call_id}
[(2) ]() . In your WebSocket handler, you can access the real call ID like this [(1) ]() :
Copy code
javascript
app.ws("/llm-websocket/:call_id",
 async (ws: WebSocket, req: Request) => {
 // callId is a unique identifier of a call, containing all information about it
 const callId = req.params.call_id;
 // You need to send the first message here, but for now let's skip that.
 ws.on("error", (err) => {
 console.error("Error received in LLM websocket client: ", err) ;
 }) ;
 ws.on("message", async (data: RawData, isBinary: boolean) => {
 // Retell server will send transcript from caller along with other information
 // You will be adding code to process and respond here
 console.log(data) ;
 }) ;
 },
) ;
## Accessing Call Details You can also get comprehensive call information by setting
call_details
to true in your config event [(2) ]() . This will send you the complete call object immediately when the WebSocket connection is established:
Copy code
json
{
 "response_type": "config",
 "config": {
 "auto_reconnect": true,
 "call_details": true
 }
}
When
call_details
is enabled, Retell will send a call details event containing the response from the Register Call API . This gives you access to the full call object with all metadata and identifiers. ## Using the Call ID for Matching The
call_id
from
req.params.call_id
is the same unique identifier used throughout the Retell AI system [(3) ]() [(4) ]() [(5) ]() [(6) ]() [(7) ]() . You can use this ID to: - Match WebSocket connections to specific calls [(2) ]() - Store the connection reference for later use in your send_info function - Authenticate in audio websockets [(3) ]() [(4) ]() [(5) ]() [(6) ]() [(7) ]() - Retrieve call information via the Get Call API [(7) ]() The call ID is consistent across all Retell AI APIs and will always be the real, active call identifier - not a placeholder [(2) ]() .
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
@AI Evy Is my agent configured to connect to wss://screener-uu36.onrender.com/llm-websocket/{call_id} for live call control? I am not seeing any WebSocket connections in my backend logs.”
a
Thanks for the follow-up, @axe9467. I'll get back to you soon.
### Answer Based on your lack of WebSocket connections in your backend logs, your agent is likely not configured to connect to your custom WebSocket endpoint [(1) ]() . Here are the key troubleshooting steps: ## Agent Configuration Check When creating agents via API, the
llm_websocket_url
parameter is required for custom LLM integrations . If you created your agent through the dashboard, it would use internal endpoints like
"wss://api.retellai.com/retell-llm-new/..."
instead of your custom endpoint . ## Common Connection Issues ### Step 1: Verify Endpoint Protocol Ensure your URL protocol matches the connection type [(2) ]() : - HTTPS Endpoints: Use
wss://
prefix for secure WebSocket connections - HTTP Endpoints: Use
ws://
prefix for standard WebSocket connections ### Step 2: Check for Trailing Slash Some server setups might not allow a trailing slash in the URL : - Correct Format: ` - Incorrect Format (sometimes) : ` ### Step 3: Add Logging to Your WebSocket Code Add logging to see if the websocket is connected and if you receive messages from Retell server . ## SSL/WSS Connection Issues There are known issues with secure WebSocket connections [(3) ]() . Some users report that Retell AI doesn't connect to secure WebSocket endpoints even when the same URL works with other tools like Postman . ## Verification Steps 1. Test your endpoint directly using Postman or another WebSocket client 2. Check if Retell is hitting your endpoint by adding connection logs 3. Verify your agent was created with the correct
llm_websocket_url
parameter 4. **Ensure your server supports WebSoc
ket connections** - some platforms like Vercel edge functions and serverless functions cannot act as a websocket server [(2) ]() If your agent was created through the dashboard rather than API, you'll need to recreate it via API with your WebSocket endpoint specified in the
llm_websocket_url
parameter [(1) ]() .
​ To learn more, see the sources I considered: [[1] Create agent via API, llm_websocket_url required](https://discord.com/channels/1186424376300679209/1247914407909130241) [[2] Troubleshooting Guide](https://docs.retellai.com/integrate-llm/troubleshooting) [[3] Issue with websocket connection on secure url with wss](https://discord.com/channels/1186424376300679209/1248670601082835087) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
@AI Evy My agent was created via the API with llm_websocket_url set to wss://screener-uu36.onrender.com/llm-websocket, but I am not seeing any WebSocket connections from Retell for live calls. Can you confirm my agent is using the correct LLM WebSocket endpoint for live call control?”
a
Thanks for the follow-up, @axe9467. I'll get back to you soon.
### Answer I cannot directly confirm your specific agent configuration, but I can help you troubleshoot why you're not seeing WebSocket connections from Retell [(1) ]() . ## Key Configuration Requirements For custom LLM WebSocket connections, your agent must be configured with the
llm_websocket_url
parameter when created via API [(2) ]() . The endpoint format should be
{your-server-websocket-endpoint}/{call_id}
[(1) ]() . ## Troubleshooting Steps ### 1. Verify Your WebSocket Server Setup Your server must handle the WebSocket connection properly [(3) ]() :
Copy code
javascript
import { RawData, WebSocket } from "ws";
import { Request } from "express";
var express = require('express') ;
var app = express() ;
var expressWs = require('express-ws') (app) ;
const port = 3000

app.ws("/llm-websocket/:call_id",
 async (ws: WebSocket, req: Request) => {
 const callId = req.params.call_id;
 ws.on("error", (err) => {
 console.error("Error received in LLM websocket client: ", err) ;
 }) ;
 ws.on("message", async (data: RawData, isBinary: boolean) => {
 console.log(data) ;
 }) ;
 },
) ;
### 2. Check IP Allowlisting Retell restricts incoming requests to allowlisted IP addresses:
100.20.5.228
. Ensure your server accepts connections from this IP. ### 3. Verify Response Engine vs LLM WebSocket URL There's been a transition from
llm_websocket_url
to
response_engine
in newer versions [(4) ]() . However, the
llm_websocket_url
field is still supported [(5) ]() . ### 4. Protocol and Connection Requirements - Your server must send the first message when the WebSocket connection is established [(1) ]() - The WebSocket uses text messages where the data attribute is a JSON object stringified - Retell AI will initiate the WebSocket connection to your server when starting a call ## Verification Methods You can verify your agent configuration by: 1. Using the List Agents API to check your agent's current configuration [(6) ]() 2. Testing your WebSocket endpoint directly with tools like Postman [(3) ]() 3. Adding connection logging to see if Retell attempts to connect If your agent was created with the correct
llm_websocket_url
parameter but you're still not seeing connections, the issue may be with your server configuration, firewall settings, or the WebSocket implementation itself.
​ To learn more, see the sources I considered: [[1] LLM WebSocket](https://docs.retellai.com/api-references/llm-websocket) [[2] Create agent via API, llm_websocket_url required](https://discord.com/channels/1186424376300679209/1247914407909130241) [[3] Setup WebSocket Server](https://docs.retellai.com/integrate-llm/setup-websocket-server) [[4] Platform Changelogs | Retell AI](https://www.retellai.com/changelog) [[5] Discord message from @wvphantomvw on 2024-11-14](https://discord.com/channels/1186424376300679209/1186462578310910112/1306674090592964699) [[6] List Agents](https://docs.retellai.com/api-references/list-agents) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
@AI Evy Subject: Retell not connecting to llm_websocket_url for live calls Message: Hi Retell Support, I have confirmed my backend WebSocket server is working and public. When I test with wscat/Postman, I see: connection However, when a real call comes in, I see: > My agent was created via the API with: llm_websocket_url: wss://screener-uu36.onrender.com/llm-websocket agent_id: agent_e4c4044a4d6785789a143c8cd0 Can you confirm that Retell is attempting to connect to my WebSocket endpoint for each live call? If not, is there an additional step or configuration required to enable live call control for my agent? Thank you!
a
Thanks for the follow-up, @axe9467. I'll get back to you soon.
### Answer Based on your description, there are several potential issues preventing Retell from connecting to your WebSocket endpoint. Let me walk through the key troubleshooting steps: ## WebSocket Connection Requirements Your WebSocket server must handle the specific path pattern that Retell uses [(1) ]() . The endpoint format is
{your-server-websocket-endpoint}/{call_id}
, so ensure your server handles the path correctly [(2) ]() :
Copy code
javascript
app.ws("/llm-websocket/:call_id",
 async (ws: WebSocket, req: Request) => {
 const callId = req.params.call_id;
 ws.on("error", (err) => {
 console.error("Error received in LLM websocket client: ", err) ;
 }) ;
 ws.on("message", async (data: RawData, isBinary: boolean) => {
 console.log(data) ;
 }) ;
 },
) ;
## Critical Configuration Points **IP Allowlisting**: Retell restricts incoming requests to allowlisted IP addresses:
100.20.5.228
. Ensure your server accepts connections from this specific IP address. **First Message Requirement**: Your server must send the first message when the WebSocket connection is established [(1) ]() . Without this, the connection may not function properly. **Protocol Format**: All WebSocket messages use text format where the data attribute is a JSON object stringified . ## Known Issues from Community There have been reports of connection issues with secure WebSocket endpoints [(3) ]() . Some users have experienced problems where Retell doesn't connect to
wss://
endpoints even when they work with other tools. ## Verification Steps 1. Add detailed logging to your WebSocket connection handler to capture any connection attempts 2. Check your server's firewall settings to ensure port access from Retell's IP 3. Verify the exact URL format - ensure there are no trailing slashes or path mismatches 4. Test the complete flow by implementing a basic response system [(2) ]() ## Testing Your WebSocket Locally You mentioned testing with wscat/Postman works, but note that the LLM WebSocket is specifically for text-based communication with Retell's system, not for audio data [(4) ]() . It's used for LLM logic and receives text requests while returning text responses. For immediate troubleshooting, I recommend creating a support ticket with Retell directly, as they can verify your specific agent configuration and check their connection logs to your endpoint.
​ To learn more, see the sources I considered: [[1] LLM WebSocket](https://docs.retellai.com/api-references/llm-websocket) [[2] Setup WebSocket Server](https://docs.retellai.com/integrate-llm/setup-websocket-server) [[3] Discord message from @wvphantomvw on 2024-11-14](https://discord.com/channels/1186424376300679209/1186462578310910112/1306674090592964699) [[4] llm-websocket/call_id endpoint not working locally](https://discord.com/channels/1186424376300679209/1237423005555232818) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.