mil_d
09/09/2025, 2:29 PMAI Evy
09/09/2025, 2:29 PMAI Evy
09/09/2025, 2:30 PMAI Evy
09/09/2025, 2:30 PMcontent_complete field [(1) ]() . According to the LLM WebSocket protocol, your response must include this boolean field .
Your response should follow this format:
javascript
export interface RetellResponse {
response_id?: number;
content: string;
content_complete: boolean;
end_call: boolean;
}
[(2) ]()
For example:
javascript
const res: RetellResponse = {
response_id: request.response_id,
content: "I am sorry, can you say that again?",
content_complete: true,
end_call: false,
};
ws.send(JSON.stringify(res) ) ;AI Evy
09/09/2025, 2:30 PMwss:// protocol incorrectly. For HTTPS endpoints, you should use wss:// prefix for secure WebSocket connections, while HTTP endpoints use ws:// prefix [(3) ]() .
Make sure your WebSocket URL format is correct:
- Correct Format: wss://your_domain_name/llm-websocket/ [(2) ]()
- Incorrect Format (sometimes) : wss://your_domain_name/llm-websocket/ with trailing slash issues [(3) ]()
## Additional Troubleshooting Steps
1. **Test with Postman**: Connect to your WebSocket URL endpoint using Postman to verify the connection works
2. **Check URL Format**: Some server setups might not allow a trailing slash in the URL
3. **Verify SSL Setup**: There have been reported issues with secure WebSocket connections where the endpoint works with tools like Postman but fails with Retell AI [(4) ]()
Check that your WebSocket server is properly handling the connection and sending correctly formatted responses with all required fields.AI Evy
09/09/2025, 2:30 PMmil_d
09/09/2025, 2:49 PMmil_d
09/09/2025, 2:50 PMAI Evy
09/09/2025, 2:50 PMAI Evy
09/09/2025, 2:50 PMAI Evy
09/09/2025, 2:50 PM/viewer/call_4b0b9926780e5d509a9f1b87d9f, but according to the Retell AI WebSocket protocol, the correct endpoint format should be {your-server-websocket-endpoint}/{call_id} [(1) ]() .
For your setup, this should be something like:
wss://voice-relay-production-2c5b.up.railway.app/llm-websocket/{call_id}
[(2) ]()
## Required WebSocket Message Flow
The connection requires your server to send the first message after the WebSocket connection is established [(1) ]() . Your server should send an initial response event:
javascript
ws.on("connection", async (ws: WebSocket, req: Request) => {
// Send first message - empty response to let user speak first
const res: RetellResponse = {
response_id: 0,
content: "",
content_complete: true,
end_call: false,
};
ws.send(JSON.stringify(res) ) ;
}) ;AI Evy
09/09/2025, 2:50 PMupdate_only and response_required events [(1) ]() .
## Debugging Steps
1. Verify WebSocket endpoint path - Ensure your agent configuration points to /llm-websocket/{call_id} not /viewer/{call_id}
2. Check initial message - Your server must send the first WebSocket message after connection
3. Monitor WebSocket messages - Log incoming messages to see if you're receiving transcript data from Retell
The successful connection upgrade indicates Railway is working correctly, but the endpoint path suggests a configuration mismatch with the expected Retell AI WebSocket protocol.AI Evy
09/09/2025, 2:50 PMmil_d
09/09/2025, 2:56 PMAI Evy
09/09/2025, 2:56 PMAI Evy
09/09/2025, 2:56 PMAI Evy
09/09/2025, 2:56 PMjavascript
ws.on("message", async (data: RawData, isBinary: boolean) => {
const request: RetellRequest = JSON.parse(data.toString() ) ;
if (request.interaction_type === "update_only") {
// Process live transcript update
console.log("Live transcript:", request.transcript) ;
return;
}
if (request.interaction_type === "response_required") {
// Send response back to Retell
const res: RetellResponse = {
response_id: request.response_id,
content: "Your response here",
content_complete: true,
end_call: false,
};
ws.send(JSON.stringify(res) ) ;
}
}) ;
[(1) ]()
## Initial Connection Message
Your server must send the first message when the WebSocket connection opens [(1) ]() [(2) ]() :
javascript
ws.on("connection", async (ws: WebSocket, req: Request) => {
// Send begin message
const res: RetellResponse = {
response_id: 0,
content: "",
content_complete: true,
end_call: false,
};
ws.send(JSON.stringify(res) ) ;
}) ;AI Evy
09/09/2025, 2:56 PMAI Evy
09/09/2025, 2:56 PMAI Evy
09/09/2025, 2:56 PMAI Evy
09/09/2025, 2:56 PMjavascript
// Initial connection setup - send first message
const initialResponse = {
response_type: "response",
response_id: 0,
content: "",
content_complete: true,
end_call: false
};
## Handling Incoming Messages
Your server should process these event types from Retell :
- update_only - Contains live transcript data
- response_required - Requires your server to respond
- reminder_required - Reminder requests
The transcript data comes in the transcript field of these events .
## Response Format
Every response must include the required fields :
javascript
{
response_type: "response",
response_id: <matching_request_id>,
content: "your response text",
content_complete: true,
end_call: false
}
Please share your actual backend code so I can identify specific issues with your implementation. The path /viewer/call_id from your Railway logs suggests the WebSocket endpoint might not be configured correctly for the LLM WebSocket protocol.AI Evy
09/09/2025, 2:56 PMmil_d
09/09/2025, 2:56 PMAI Evy
09/09/2025, 2:56 PMAI Evy
09/09/2025, 2:56 PMjavascript
app.ws("/llm-websocket/:call_id",
async (ws: WebSocket, req: Request) => {
const callId = req.params.call_id;
// Your WebSocket handling code here
}
) ;
[(2) ]()
## Required Message Flow
Your server must send the first message after connection :
javascript
// Send Begin message
const res: RetellResponse = {
response_id: 0,
content: "How may I help you?",
content_complete: true,
end_call: false,
};
ws.send(JSON.stringify(res) ) ;
## Handling Incoming Messages
Your server needs to process different interaction types [(1) ]() :
javascript
ws.on("message", async (data: RawData, isBinary: boolean) => {
const request: RetellRequest = JSON.parse(data.toString() ) ;
if (request.interaction_type === "update_only") {
// Process live transcript update
return;
}
if (request.interaction_type === "response_required") {
// Send response back
}
}) ;
[(2) ]()
Please share your code so I can identify the specific issues causing your live transcript problems.AI Evy
09/09/2025, 2:56 PMAI Evy
09/09/2025, 2:57 PMmil_d
09/09/2025, 2:58 PMAI Evy
09/09/2025, 2:58 PMAI Evy
09/09/2025, 2:58 PMjavascript
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) ;
}) ;
},
) ;
## Required Response Format
Your code needs to handle Retell's specific message protocol [(1) ]() . When Retell sends messages to your server, you must respond with this format [(2) ]() :
javascript
export interface RetellResponse {
response_id?: number;
content: string;
content_complete: boolean;
end_call: boolean;
}AI Evy
09/09/2025, 2:58 PMAI Evy
09/09/2025, 2:58 PMAI Evy
09/09/2025, 2:58 PMmil_d
09/09/2025, 2:58 PMAI Evy
09/09/2025, 2:59 PMAI Evy
09/09/2025, 2:59 PMAI Evy
09/09/2025, 2:59 PMjavascript
export interface RetellResponse {
response_id?: number;
content: string;
content_complete: boolean;
end_call: boolean;
}
Please share parts 3/4 and 4/4 so I can see if you have the LLM WebSocket endpoint implementation. The viewer WebSocket is good for displaying transcripts, but you need the LLM WebSocket to receive live transcript data from Retell AI.AI Evy
09/09/2025, 2:59 PM/llm-websocket/:call_id endpoint that Retell AI connects to [(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) ;
}) ;
},
) ;
## Protocol Mismatch
Your viewer WebSocket expects messages like { type: "snapshot", items: [...] }, but Retell AI sends messages following the LLM WebSocket protocol [(2) ]() :
- interaction_type: "update_only" - contains live transcript data
- interaction_type: "response_required" - requires your server to respond
- interaction_type: "reminder_required" - reminder requests
## Required Response Format
When Retell sends messages to your LLM WebSocket endpoint, you must respond with this exact format [(1) ]() :AI Evy
09/09/2025, 2:59 PMmil_d
09/09/2025, 2:59 PMAI Evy
09/09/2025, 2:59 PMAI Evy
09/09/2025, 2:59 PMjavascript
llmWss.on("connection", (ws, req) => {
// ... your existing code ...
// Send Begin message immediately after connection
const res = {
response_id: 0,
content: "How may I help you?",
content_complete: true,
end_call: false,
};
ws.send(JSON.stringify(res) ) ;
}) ;
[(1) ]()
## Protocol Message Handling
Your server must handle Retell's specific message format [(2) ]() . You need to process these interaction_type values:AI Evy
09/09/2025, 2:59 PMjavascript
ws.on("message", async (data, isBinary) => {
if (isBinary) {
console.error("Got binary message instead of text in websocket.") ;
ws.close(1002, "Cannot find corresponding Retell LLM.") ;
}
try {
const request = JSON.parse(data.toString() ) ;
if (request.interaction_type === "update_only") {
// Process live transcript update - this is where you get live transcripts
mergeTrimmed(getRoom(callId) , request.transcript) ;
sendSnapshot(callId) ;
return;
}
if (request.interaction_type === "response_required") {
// Send response back to Retell
const response = {
response_id: request.response_id,
content: minimalBrainReply(request.transcript) ,
content_complete: true,
end_call: false,
};
ws.send(JSON.stringify(response) ) ;
}
} catch (err) {
console.error("Error in parsing LLM websocket message: ", err) ;
ws.close(1002, "Cannot parse incoming message.") ;
}
}) ;
[(1) ]()
## Endpoint Path Issue
Your Railway logs showed /viewer/call_id but the LLM WebSocket should be /llm-websocket/{call_id} [(2) ]() . Make sure your agent configuration points to the correct endpoint.
Please share part 4/4 so I can see your complete message handling implementation.AI Evy
09/09/2025, 2:59 PMAI Evy
09/09/2025, 2:59 PMmil_d
09/09/2025, 3:00 PM[llm] WS connected path=${cleanPath} callId=${callId || "(pending)"});
// Send CONFIG (so Retell streams call details + pings)
try {
ws.send(JSON.stringify({ response_type: "config", config: { call_details: true, auto_reconnect: true } }));
} catch {}
// Per your note: send an initial empty response so the user/broker can speak first
try {
ws.send(JSON.stringify({ response_id: 0, content: "", content_complete: true, end_call: false }));
} catch {}
ws.on("message", (buf) => {
let msg; try { msg = JSON.parse(buf.toString()); } catch { return; }
// Learn callId from call_details if not provided in URL
if (!callId && msg?.call_details?.call_id) {
callId = msg.call_details.call_id;
room = getRoom(callId);
console.log([llm] learned callId from call_details: ${callId});
}
if (!room) return;
if (msg.interaction_type === "update_only" && Array.isArray(msg.transcript)) {
// Live updates — merge trimmed segments and snapshot viewers
mergeTrimmed(room, msg.transcript);
sendSnapshot(callId);
return;AI Evy
09/09/2025, 3:00 PMAI Evy
09/09/2025, 3:00 PMmil_d
09/09/2025, 3:00 PMAI Evy
09/09/2025, 3:00 PM/viewer/call_id, make sure your agent's llm_websocket_url is configured to point to /llm-websocket/{call_id} or /llm/{call_id} (based on your path parsing) [(1) ]() [(2) ]() .
## Auto-Reconnect Implementation
Since you're using auto_reconnect: true, you should also handle ping-pong events [(2) ]() :
javascript
if (msg.interaction_type === "ping_pong") {
ws.send(JSON.stringify({
response_type: "ping_pong",
timestamp: msg.timestamp
}) ) ;
return;
}
Please share the rest of your code so I can see your complete response_required handling implementation.AI Evy
09/09/2025, 3:00 PMAI Evy
09/09/2025, 3:00 PMresponse_type field [(2) ]() . The correct format should be:
javascript
ws.send(JSON.stringify({
response_type: "config",
config: {
call_details: true,
auto_reconnect: true
}
}) ) ;
## Initial Response Format
Your initial response looks correct, but make sure it follows the exact protocol [(1) ]() [(2) ]() :
javascript
ws.send(JSON.stringify({
response_id: 0,
content: "",
content_complete: true,
end_call: false
}) ) ;
[(1) ]()
## Missing Response Event Type
When you handle response_required and reminder_required events, your responses need the response_type field [(2) ]() . You should respond with:
javascript
const res = {
response_type: "response",
response_id: request.response_id,
content: "Your response here",
content_complete: true,
end_call: false,
};
ws.send(JSON.stringify(res) ) ;AI Evy
09/09/2025, 3:00 PMAI Evy
09/09/2025, 3:00 PMmil_d
09/09/2025, 3:00 PM[relay] listening on ${PORT}));AI Evy
09/09/2025, 3:00 PMresponse_type field [(1) ]() . According to the LLM WebSocket protocol, your responses should include this field :
javascript
// Your current format:
ws.send(JSON.stringify({
response_id: msg.response_id,
content: reply,
content_complete: true,
end_call: false
}) ) ;
// Should be:
ws.send(JSON.stringify({
response_type: "response",
response_id: msg.response_id,
content: reply,
content_complete: true,
end_call: false
}) ) ;
## Initial Message Format
Your initial message also needs the response_type field :
javascript
// Your current format:
ws.send(JSON.stringify({ response_id: 0, content: "", content_complete: true, end_call: false }) ) ;
// Should be:
ws.send(JSON.stringify({
response_type: "response",
response_id: 0,
content: "",
content_complete: true,
end_call: false
}) ) ;
## WebSocket Server Upgrade Issue
You're using a separate WebSocketServer with noServer: true, but you need to properly handle the HTTP upgrade for the LLM WebSocket endpoint [(2) ]() . The typical approach is to use express-ws or handle the upgrade manually:
javascript
app.ws("/llm-websocket/:call_id",
async (ws: WebSocket, req: Request) => {
const callId = req.params.call_id;
// Your WebSocket handling code here
}
) ;AI Evy
09/09/2025, 3:00 PMwss://voice-relay-production-2c5b.up.railway.app/llm-websocket/
The path /viewer/call_id in your Railway logs suggests the agent might be connecting to the wrong endpoint. Your LLM WebSocket should be accessible at /llm-websocket/{call_id} [(1) ]() .
Please share the final part of your code so I can see how you handle the HTTP server upgrade for WebSocket connections.AI Evy
09/09/2025, 3:01 PMAI Evy
09/09/2025, 3:01 PMAI Evy
09/09/2025, 3:01 PMresponse_type field [(1) ]() . When handling response_required and reminder_required events, you must include response_type: "response" :
javascript
if (msg.interaction_type === "response_required") {
const reply = BRAIN === "off" ? "" : minimalBrainReply(room.transcript) ;
ws.send(JSON.stringify({
response_type: "response", // <- This is missing in your code
response_id: msg.response_id,
content: reply,
content_complete: true,
end_call: false
}) ) ;
return;
}
## Critical Issue 2: Missing Ping-Pong Handling
Since you're using auto_reconnect: true, you must handle ping-pong events . Add this to your message handler:
javascript
if (msg.interaction_type === "ping_pong") {
ws.send(JSON.stringify({
response_type: "ping_pong",
timestamp: msg.timestamp
}) ) ;
return;
}
This matches the issue reported in the Discord community where users don't receive ping-pong events when auto_reconnect is enabled [(2) ]() .
## Issue 3: Initial Response Missing Response Type
Your initial response should also include response_type [(1) ]() :
javascript
// Per your note: send an initial empty response so the user/broker can speak first
try {
ws.send(JSON.stringify({
response_type: "response", // <- Add this
response_id: 0,
content: "",
content_complete: true,
end_call: false
}) ) ;
} catch {}AI Evy
09/09/2025, 3:01 PMcontent_complete not a boolean {"response":""} [(1) ]() . This suggests you're sending an incorrect response format somewhere. Make sure all responses follow the exact format :
javascript
{
response_type: "response",
response_id: request.response_id,
content: "your response text",
content_complete: true,
end_call: false
}
## Issue 5: Endpoint Configuration
Your Railway logs show /viewer/call_id but your LLM WebSocket should use /llm-websocket/{call_id} . Make sure your agent's llm_websocket_url points to the correct endpoint format [(3) ]() .
## Recommended Fixes
1. Add response_type: "response" to all your response messages [(1) ]()
2. Implement ping-pong handling for auto-reconnect
3. Add response_type: "response" to your initial message [(3) ]()
4. Verify your agent configuration uses the correct WebSocket URL format [(1) ]()
These changes should resolve your live transcript issues and the parsing errors you're seeing in the call logs.AI Evy
09/09/2025, 3:01 PMAI Evy
09/09/2025, 3:01 PMerror_llm_websocket_runtime](https://discord.com/channels/1186424376300679209/1298564756504055852)
[[3] Setup WebSocket Server](https://docs.retellai.com/integrate-llm/setup-websocket-server)
mil_d
09/09/2025, 3:21 PMAI Evy
09/09/2025, 3:21 PMAI Evy
09/09/2025, 3:22 PMupdate_only events with transcript data [(1) ]() . The remaining error is in your initial message format.
## Fix the Initial Message Format
The error content_complete not a boolean {"response":""} shows you're still sending an incorrect initial message format . Based on the LLM WebSocket protocol, your initial message should be [(2) ]() :
javascript
// Send Begin message immediately after connection
const res = {
response_id: 0,
content: "",
content_complete: true,
end_call: false,
};
ws.send(JSON.stringify(res) ) ;AI Evy
09/09/2025, 3:22 PM{"response":""} anywhere in your code. The correct initial response format must include all required fields [(1) ]() .
## Webhook Protocol Error
The webhook error Unsupported protocol wss: suggests you have a webhook URL configured with wss:// protocol [(3) ]() . Webhooks should use ` not wss:// since they're HTTP POST requests, not WebSocket connections .
## Your Live Transcripts Are Working
The good news is your live transcript functionality is now working correctly! The logs show Retell is successfully sending you:
- interaction_type: 'update_only' events with transcript data [(1) ]()
- turntaking: 'user_turn' events
- Live transcript updates with user speech content
Your mergeTrimmed() function should be receiving these updates and broadcasting them to your viewer WebSocket clients.
## Summary
1. Fix your initial message to use the exact format from the documentation [(2) ]()
2. Change any webhook URLs from wss:// to ` [(3) ]()
3. Your live transcripts are already working - you should see the data flowing to your viewer clientsAI Evy
09/09/2025, 3:22 PMAI Evy
09/09/2025, 3:22 PMmil_d
09/09/2025, 3:32 PMAI Evy
09/09/2025, 3:32 PMAI Evy
09/09/2025, 3:32 PMwss:// for WebSocket connections [(1) ]() . The LLM WebSocket endpoint requires a secure WebSocket protocol .
## Double Slash Issue
You have a double slash //llm-websocket/ which should be a single slash /llm-websocket/ .
## Correct Format
The correct Custom LLM URL format should be :
wss://voice-relay-production-2c5b.up.railway.app/llm-websocket/{call_id}?token=2d28507a249bca712948ef8fc04c5bd9ef6b934f74113d2f74f725b70c7ca87888ceb824e67c09511fa6f99cd7731511
## WebSocket Endpoint Specification
According to the documentation, the WebSocket endpoint should follow this format :
WebSocket Endpoint: {your-server-websocket-endpoint}/{call_id}
Where {call_id} is a unique call identifier .
## Testing Your Endpoint
You can test your WebSocket connection using Postman [(2) ]() :
1. Open Postman and create a new WebSocket request
2. Enter your WebSocket URL and click "Connect"
3. Navigate to the "Message" tab, enter "Hello", and click "Send"
You should receive the message back in your server indicating a successful connection .
Make sure your server is properly handling the WebSocket upgrade for the /llm-websocket/ path as shown in your code.AI Evy
09/09/2025, 3:32 PMAI Evy
09/09/2025, 3:32 PMmil_d
09/09/2025, 3:39 PMAI Evy
09/09/2025, 3:39 PMAI Evy
09/09/2025, 3:39 PMwss://voice-relay-production-2c5b.up.railway.app/llm-websocket/{call_id}?token=2d28507a249bca712948ef8fc04c5bd9ef6b934f74113d2f74f725b70c7ca87888ceb824e67c09511fa6f99cd7731511
The WebSocket endpoint specification requires this format [(2) ]() :
WebSocket Endpoint: {your-server-websocket-endpoint}/{call_id}
Where call_id is a unique call identifier .
If you're still seeing errors, please share the Railway logs so I can help identify what's happening with your WebSocket connection and message handling.AI Evy
09/09/2025, 3:39 PMAI Evy
09/09/2025, 3:39 PMmil_d
09/09/2025, 3:39 PMAI Evy
09/09/2025, 3:39 PMAI Evy
09/09/2025, 3:40 PM//llm-websocket/{call_id} with a double slash, which returns a 404 error [(1) ]() .
## URL Format Issue
Your Custom LLM URL has the double slash issue we identified earlier. You configured:
<https://voice-relay-production-2c5b.up.railway.app//llm-websocket/%7Bcall_id%7D>
But it should be:
wss://voice-relay-production-2c5b.up.railway.app/llm-websocket/{call_id}?token=your_token
## Two Critical Fixes Needed
1. **Remove the double slash**: Change //llm-websocket/ to /llm-websocket/
2. **Use WebSocket protocol**: Change ` to wss:// for WebSocket connections [(2) ]()
## Correct WebSocket Endpoint Format
According to the LLM WebSocket documentation, the endpoint should follow this format :
WebSocket Endpoint: {your-server-websocket-endpoint}/{call_id}
Where call_id is a unique call identifier .
## Check Your Server Configuration
Your server upgrade handler correctly handles both /llm and /llm-websocket paths, but make sure the trailing slash handling is working properly [(1) ]() :
javascript
const cleanPath = (u.pathname || "") .replace(/\/+$/, "") ; // tolerate trailing slash
const isLlm = cleanPath.startsWith("/llm") || cleanPath.startsWith("/llm-websocket") ;
Update your agent's Custom LLM URL to use the correct format with wss:// protocol and single slash, and the 404 errors should resolve.AI Evy
09/09/2025, 3:40 PMAI Evy
09/09/2025, 3:40 PMmil_d
09/09/2025, 4:16 PMAI Evy
09/09/2025, 4:16 PMAI Evy
09/09/2025, 4:17 PMUnsupported protocol wss: indicates you have a webhook URL configured with the wss:// protocol [(1) ]() . This is incorrect - webhooks are HTTP POST requests, not WebSocket connections .
## Webhook vs WebSocket URLs
You need to configure two different URLs in your Retell AI agent:
1. **Custom LLM WebSocket URL**: Uses wss:// protocol for live transcripts
2. **Webhook URL**: Uses ` protocol for event notifications
## Fix Your Webhook Configuration
Your webhook URL should use ` not wss:// . Webhooks are HTTP POST requests that Retell AI sends to notify your application about events like call_started, call_ended, and call_analyzed .
The webhook will POST the payload to your endpoint with a timeout of 10 seconds . If no success status (2xx) is received within 10 seconds, the webhook will be retried up to 3 times .
## Webhook Endpoint Format
Your webhook endpoint should be something like:
<https://voice-relay-production-2c5b.up.railway.app/webhook>
## Sample Webhook Handler
According to the documentation, here's how to handle webhooks properly [(2) ]() :
javascript
app.post("/webhook", (req: Request, res: Response) => {
if (
!Retell.verify(
JSON.stringify(req.body) ,
process.env.RETELL_API_KEY,
req.headers["x-retell-signature"] as string,
)
) {
console.error("Invalid signature") ;
return;
}
const {event, call} = req.body;
// process the webhook
// Acknowledge the receipt of the event
res.status(204) .send() ;
}) ;AI Evy
09/09/2025, 4:17 PMAI Evy
09/09/2025, 4:17 PMmil_d
09/09/2025, 6:16 PMAI Evy
09/09/2025, 6:16 PMAI Evy
09/09/2025, 6:17 PMend_call: true :
javascript
// When user clicks "End Call" button
const endCallResponse = {
response_type: "response",
response_id: currentResponseId, // Use the current response_id from Retell
content: "Thank you for calling. Have a great day!",
content_complete: true,
end_call: true
};
ws.send(JSON.stringify(endCallResponse) ) ;
## Transfer Call Button
For call transfers with Custom LLM, you can trigger a cold transfer by setting the transfer_number field in your response event :
javascript
// When user clicks "Transfer Call" button
const transferResponse = {
response_type: "response",
response_id: currentResponseId,
content: "Let me transfer you to the right department.",
content_complete: true,
end_call: false,
transfer_number: "+1234567890" // The number to transfer to
};
ws.send(JSON.stringify(transferResponse) ) ;
## Implementation in Your Live Transcript Window
Based on your existing WebSocket setup, you can add these buttons to your viewer interface and send commands to your LLM WebSocket server:
javascript
// In your viewer WebSocket client
function endCall() {
// Send command to your server to trigger end call
viewerWs.send(JSON.stringify({
action: "end_call",
callId: currentCallId
}) ) ;
}
function transferCall(transferNumber) {
// Send command to your server to trigger transfer
viewerWs.send(JSON.stringify({
action: "transfer_call",
callId: currentCallId,
transferNumber: transferNumber
}) ) ;
}AI Evy
09/09/2025, 6:17 PMAI Evy
09/09/2025, 6:17 PMAI Evy
09/09/2025, 6:17 PMmil_d
09/09/2025, 6:53 PMAI Evy
09/09/2025, 6:53 PMAI Evy
09/09/2025, 6:53 PMAI Evy
09/09/2025, 6:53 PMend_call and transfer_number fields only take effect after the content is fully spoken :
- `end_call`: "If set to true, Retell would end the call after content associated with this id is fully spoken"
- `transfer_number`: "If set, Retell would transfer the call to the number specified here after content associated with this id is fully spoken"
## Solution: Use Agent Interrupt Event
To execute these actions immediately, you should use the Agent Interrupt Event instead of a regular response event :
javascript
// For immediate end call
const endCallInterrupt = {
response_type: "agent_interrupt",
interrupt_id: Date.now() , // Unique interrupt ID
content: "Goodbye!",
content_complete: true,
end_call: true,
no_interruption_allowed: true // Recommended for interrupts
};
ws.send(JSON.stringify(endCallInterrupt) ) ;
javascript
// For immediate transfer
const transferInterrupt = {
response_type: "agent_interrupt",
interrupt_id: Date.now() ,
content: "Transferring now...",
content_complete: true,
transfer_number: "+1234567890",
no_interruption_allowed: true
};
ws.send(JSON.stringify(transferInterrupt) ) ;AI Evy
09/09/2025, 6:53 PMno_interruption_allowed: true setting is recommended because "without this setting, if user is talking, and agent interrupts here, the two party would speak at the same time, and agent would get interrupted quickly" .
Update your button handlers to use agent_interrupt instead of regular response events for immediate execution of end call and transfer actions.AI Evy
09/09/2025, 6:53 PMmil_d
09/09/2025, 7:17 PMAI Evy
09/09/2025, 7:17 PMmil_d
09/09/2025, 7:17 PMAI Evy
09/09/2025, 7:17 PMAI Evy
09/09/2025, 7:17 PMphrase Variable Initialization
The error ReferenceError: Cannot access 'phrase' before initialization at line 437 indicates you're trying to use a variable phrase before it's declared or in a temporal dead zone. This typically happens with let or const declarations.
**Fix**: Ensure phrase is declared before it's used:
javascript
// Make sure phrase is declared before use
let phrase = ""; // or const phrase = someValue;
// Then use phrase
## Error 2: notifyControl Function Not Defined
The error ReferenceError: notifyControl is not defined at line 459 means you're calling a function that doesn't exist.
**Fix**: You need to define the notifyControl function or check if you meant to call a different function. Based on your earlier code, you might need:
javascript
// Define the function
function notifyControl(callId, message) {
// Your notification logic here
const room = getRoom(callId) ;
// Send update to viewers or handle control notification
}
// Or if you meant to call sendUpdate:
sendUpdate(callId, message) ;
## Debugging Steps
1. **Check line 437**: Look for where phrase is used and ensure it's properly declared
2. **Check line 459**: Verify the notifyControl function exists or replace it with the correct function call
3. **Variable scope**: Make sure all variables are declared in the correct scope
These are standard JavaScript coding errors unrelated to Retell AI's WebSocket protocol. The errors are preventing your control endpoint from working properly, which would affect your End Call and Transfer Call buttons.AI Evy
09/09/2025, 7:17 PMAI Evy
09/09/2025, 7:18 PMmil_d
09/09/2025, 7:18 PMAI Evy
09/09/2025, 7:18 PMphrase variable is being used before initialization
2. **Line 459**: notifyControl function is not defined
These need to be resolved in your server code before the Retell AI WebSocket events will work.
## Correct Agent Interrupt Event Format
Once your JavaScript errors are fixed, make sure you're sending the Agent Interrupt Event in the correct format for immediate end call execution [(1) ]() :
javascript
{
"response_type": "agent_interrupt",
"interrupt_id": 123,
"content": "Goodbye!",
"content_complete": true,
"end_call": true,
"no_interruption_allowed": true
}
## Why Agent Interrupt is Needed
The Agent Interrupt Event will immediately "stop the agent speech if the agent is speaking, or it will interrupt the user if the user is speaking" . This provides immediate execution rather than queuing the action like regular response events.
The no_interruption_allowed: true setting is recommended because "without this setting, if user is talking, and agent interrupts here, the two party would speak at the same time, and agent would get interrupted quickly" .
Fix your JavaScript errors first, then the Agent Interrupt Event should execute the end call immediately instead of showing "End call queued".AI Evy
09/09/2025, 7:18 PMAI Evy
09/09/2025, 7:18 PMmil_d
09/10/2025, 4:52 PMAI Evy
09/10/2025, 4:52 PMretell_llm_dynamic_variables field of the call details event [(1) ]() .AI Evy
09/10/2025, 4:52 PMjavascript
// Send config event to enable call details
{
"response_type": "config",
"config": {
"auto_reconnect": true,
"call_details": true
}
}
## Call Details Event Structure
When call details are enabled, Retell will send you the dynamic variables in this format :
javascript
{
"interaction_type": "call_details",
"call": {
"call_id": "call_123",
"agent_id": "agent_456",
"retell_llm_dynamic_variables": {
"customer_name": "John Doe",
"product_name": "Premium Plan",
"account_status": "active"
}
}
}
## Implementation Example
Based on the Node.js demo structure [(2) ]() , here's how to handle dynamic variables in your Custom LLM:
typescript
export interface RetellRequest {
response_id?: number;
transcript: Utterance[];
interaction_type: "update_only" | "response_required" | "reminder_required";
}
Store the dynamic variables when you receive the call details event, then inject them into your prompt preparation:
typescript
private PreparePrompt(request: RetellRequest) {
let transcript = this.ConversationToChatRequestMessages(request.transcript) ;
let requestMessages: ChatRequestMessage[] = [
{
role: "system",
content: agentPrompt + this.getDynamicVariableContext()
},
];
// ... rest of prompt preparation
}AI Evy
09/10/2025, 4:52 PMAI Evy
09/10/2025, 4:52 PMAI Evy
09/10/2025, 4:53 PMmil_d
09/10/2025, 4:57 PMAI Evy
09/10/2025, 4:57 PMAI Evy
09/10/2025, 4:57 PMwss:// protocol somewhere in your agent settings [(1) ]() . This is causing the error because webhooks must use the ` protocol, not wss:// [(1) ]() [(2) ]() .
The error Unsupported protocol wss: indicates that somewhere in your agent configuration, a webhook URL is set to use the WebSocket protocol instead of HTTPS .
## Check These Settings
1. **Agent Level Webhook URL**: Should use ` format like `"
2. **Account Level Webhook**: If configured, should also use `
3. **Phone Number Webhook**: If you have inbound call webhooks configured, these should also use ` [(3) ]()
## Webhook URL Format
The webhook URL should be configured as [(1) ]() [(2) ]() :
webhook_url: "<https://webhook-url-here%22>AI Evy
09/10/2025, 4:57 PMwss:// protocol
- **Webhook URLs**: Use ` protocol for HTTP POST requests
## Troubleshooting Steps
1. Check your agent's webhook configuration in the dashboard
2. Verify no webhook URLs are using wss:// protocol
3. If you have both inbound call webhooks and agent level webhooks, ensure both use ` [(3) ]()
The webhook timeout is set to 10000ms by default, and if not set, this default value will apply [(1) ]() [(2) ]() .
From the Discord discussions, there have been previous issues with webhook URL saving that were resolved [(3) ]() [(4) ]() . Double-check that your webhook URL is properly saved and uses the correct ` protocol.AI Evy
09/10/2025, 4:57 PMAI Evy
09/10/2025, 4:57 PMmil_d
09/11/2025, 5:59 PMAI Evy
09/11/2025, 5:59 PMAI Evy
09/11/2025, 5:59 PMresponse_id and not sending responses if they are stale .
This is normal behavior for live speechAI Evy
09/11/2025, 5:59 PMAI Evy
09/11/2025, 5:59 PMAI Evy
09/11/2025, 5:59 PMmil_d
09/11/2025, 6:01 PMAI Evy
09/11/2025, 6:01 PMAI Evy
09/11/2025, 6:01 PMturntaking field indicates "change of speaker (turn taking) " and will be present when speaker changes to user (user_turn) or right before agent is about to speak (agent_turn) .
## Why You See Updates Without Speech
Even when the customer hasn't spoken, Retell AI may send Update Only Events because :
1. **Turntaking detection**: The system is detecting potential speaker changes
2. **Agent preparation**: Right before the agent is about to speak, you'll receive an event with turntaking: "agent_turn"
3. **Silence processing**: The system may be processing periods of silence to determine next actions
## Event Structure During Silence
During periods when no one is speaking, you might still receive events like:
json
{
"interaction_type": "update_only",
"transcript": [...],
"turntaking": "agent_turn"
}
## How to Handle This
The Update Only Events are informational and "no response required" . You should process these events to stay updated on the call state but not generate responses unless you receive a response_required or reminder_required event .
This behavior ensures your system stays synchronized with Retell AI's call state, even during periods of silence or speaker transitions.AI Evy
09/11/2025, 6:01 PMAI Evy
09/11/2025, 6:02 PMmil_d
09/12/2025, 3:25 PMAI Evy
09/12/2025, 3:25 PMAI Evy
09/12/2025, 3:26 PMwords array which contains timestamp information. However, the current Custom LLM WebSocket implementation has limitations [(2) ]() .
From the Discord discussion, users have requested: "Can the 'words' list with timestamp (like in rest api call) be provided for custom llm update object?"
## Workaround Approaches
Since there are known issues with live transcript synchronization in Custom LLM implementations , some users have had to "disable transcripts" due to the problems .
For aAI Evy
09/12/2025, 3:26 PMcontent field from transcript updates more carefully
2. Handle the fact that "the entire transcript appears while the AI is still speaking"
3. Account for the timing mismatch between audio and transcript
## Current Limitations
The live transcript functionality in Custom LLM has known issues that are "hampering user experience" and "damaging demos" according to multiple users in the Discord community . This appears to be a system-level issue rather than an implementation problem on your end.
Until these core transcript synchronization issues are resolved, achieving perfect parity with Retell's Agent Testing live transcript display may not be possible with Custom LLM implementations .AI Evy
09/12/2025, 3:26 PMAI Evy
09/12/2025, 3:26 PMmil_d
09/12/2025, 3:34 PMAI Evy
09/12/2025, 3:34 PMAI Evy
09/12/2025, 3:34 PMupdate_only events are sent continuously as the transcript updates and during turntaking events .
## Potential Server-Side Solutions
While you can't control Retell AI's message frequency, you can implement throttling on your server side:
1. **Debouncing**: Only process the latest update after a brief delay
2. **Response ID Checking**: The GitHub demo repositories include mechanisms to handle potentially duplicate transcripts by checking the latest value of response_id and not sending responses if they are stale
## Important Distinction
Remember that update_only events require no response . You should only generate responses when you receive:
- response_required events
- reminder_required events
## Streaming Response Timing
From the Discord discussion, there are some timing considerations for streaming responses. If you don't send any data within 1 second, Retell AI will trigger audio generation anyway [(2) ]() . Additionally, complete sentences with punctuation will trigger audio generation .
The multiple updates are by design to keep your system synchronized with the live transcript corrections, but you can implement your own server-side logic to reduce processing overhead while still maintaining responsiveness to actual response requests.AI Evy
09/12/2025, 3:34 PMAI Evy
09/12/2025, 3:34 PMmil_d
09/12/2025, 6:40 PMAI Evy
09/12/2025, 6:40 PMAI Evy
09/12/2025, 6:40 PMcontent_complete field [(1) ]() . The agent isn't speaking because Retell AI can't parse your response message properly.
## Fix the Missing Field
Your current message structure is missing the required content_complete boolean field :
json
{
"response_id": 2,
"interaction_type": "response",
"content": "Hi, this is Anna with Max Trucking. I'm calling about your load from Chicago, IL to Cleveland, OH."
}
## Correct Response Event Format
According to the LLM WebSocket specification, the Response Event requires these fields :
- `response_type`: Must be "response"
- `response_id`: Integer indicating which requested response this is answering
- `content`: The response content
- `content_complete`: Boolean indicating whether the content is complete
Here's the corrected format :
json
{
"response_type": "response",
"response_id": 2,
"content": "Hi, this is Anna with Max Trucking. I'm calling about your load from Chicago, IL to Cleveland, OH.",
"content_complete": true
}AI Evy
09/12/2025, 6:40 PMcontent_complete: true tells Retell AI that your response is finished and ready to be spoken .
## Implementation Fix
Make sure your response sending function includes the content_complete field:
typescript
const res: CustomLlmResponse = {
response_type: "response",
response_id: response_id,
content: content,
content_complete: true,
end_call: false
};
ws.send(JSON.stringify(res) ) ;
Once you add the missing content_complete: true field, your agent should start speaking properly.AI Evy
09/12/2025, 6:40 PMAI Evy
09/12/2025, 6:40 PM