axe9467
08/18/2025, 4:29 PMAI Evy
08/18/2025, 4:29 PMAI Evy
08/18/2025, 4:29 PMtransfer_number field in a response event :
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 :
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 .AI Evy
08/18/2025, 4:29 PMAI Evy
08/18/2025, 4:29 PMaxe9467
08/18/2025, 4:32 PMAI Evy
08/18/2025, 4:32 PMAI Evy
08/18/2025, 4:33 PM{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:
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) ]() :
json
{
"response_type": "response",
"response_id": 1,
"content": "I'll transfer you now.",
"content_complete": true,
"transfer_number": "+1234567890"
}AI Evy
08/18/2025, 4:33 PMjson
{
"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 :
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 :
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]()AI Evy
08/18/2025, 4:33 PMAI Evy
08/18/2025, 4:33 PMaxe9467
08/18/2025, 4:52 PMAI Evy
08/18/2025, 4:52 PMAI Evy
08/18/2025, 4:52 PMwss://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) ]() :
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) ;
}) ;
},
) ;AI Evy
08/18/2025, 4:52 PM100.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 .AI Evy
08/18/2025, 4:52 PMAI Evy
08/18/2025, 4:52 PMaxe9467
08/18/2025, 6:05 PMAI Evy
08/18/2025, 6:05 PMAI Evy
08/18/2025, 6:06 PMllm_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.AI Evy
08/18/2025, 6:06 PMAI Evy
08/18/2025, 6:06 PMaxe9467
08/18/2025, 6:19 PMAI Evy
08/18/2025, 6:19 PMAI Evy
08/18/2025, 6:19 PMwss://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.AI Evy
08/18/2025, 6:19 PM{your-server-websocket-endpoint}/{call_id} [(2) ]() .
Here's how to set up your WebSocket server [(1) ]() :
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}`)
}) ;AI Evy
08/18/2025, 6:19 PMAI Evy
08/18/2025, 6:19 PMaxe9467
08/18/2025, 6:40 PMAI Evy
08/18/2025, 6:40 PMAI Evy
08/18/2025, 6:41 PMllm_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:
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) ;
}) ;
},
) ;AI Evy
08/18/2025, 6:41 PM100.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.AI Evy
08/18/2025, 6:41 PMAI Evy
08/18/2025, 6:41 PMaxe9467
08/18/2025, 7:12 PMAI Evy
08/18/2025, 7:12 PMAI Evy
08/18/2025, 7:12 PMresponse_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 :
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) ]() :
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) ;AI Evy
08/18/2025, 7:12 PMAI Evy
08/18/2025, 7:12 PMaxe9467
08/18/2025, 8:46 PMAI Evy
08/18/2025, 8:46 PMAI Evy
08/18/2025, 8:46 PM{your-server-websocket-endpoint}/{call_id} [(2) ]() .
In your WebSocket handler, you can access the real call ID like this [(1) ]() :
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:
json
{
"response_type": "config",
"config": {
"auto_reconnect": true,
"call_details": true
}
}AI Evy
08/18/2025, 8:46 PMcall_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) ]() .AI Evy
08/18/2025, 8:46 PMAI Evy
08/18/2025, 8:46 PMaxe9467
08/18/2025, 8:53 PMAI Evy
08/18/2025, 8:53 PMAI Evy
08/18/2025, 8:53 PMllm_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 WebSocAI Evy
08/18/2025, 8:53 PMllm_websocket_url parameter [(1) ]() .AI Evy
08/18/2025, 8:54 PMAI Evy
08/18/2025, 8:54 PMaxe9467
08/18/2025, 10:42 PMAI Evy
08/18/2025, 10:42 PMAI Evy
08/18/2025, 10:42 PMllm_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) ]() :
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) ;
}) ;
},
) ;AI Evy
08/18/2025, 10:42 PM100.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.AI Evy
08/18/2025, 10:42 PMAI Evy
08/18/2025, 10:42 PMaxe9467
08/18/2025, 11:06 PMAI Evy
08/18/2025, 11:06 PMAI Evy
08/18/2025, 11:07 PM{your-server-websocket-endpoint}/{call_id}, so ensure your server handles the path correctly [(2) ]() :
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) ;
}) ;
},
) ;AI Evy
08/18/2025, 11:07 PM100.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.AI Evy
08/18/2025, 11:07 PMAI Evy
08/18/2025, 11:07 PM