trumliem
09/11/2025, 7:32 AMAI Evy
09/11/2025, 7:33 AMAI Evy
09/11/2025, 7:33 AMmax_call_duration_ms setting that allows you to programmatically limit call duration [(1) ]() [(2) ]() .
According to the documentation, you can set the maximum call duration when configuring your agent . The default maximum duration is 1 hour (3600000 milliseconds) , but you can customize this value [(3) ]() [(1) ]() [(2) ]() .
For your graduation project scenario, you could:
1. Track each user's remaining call time in your system
2. When a user initiates a call, calculate their remaining minutes from their 4-minute package
3. Set the max_call_duration_ms parameter to automatically end the call when they reach their limit [(1) ]() [(2) ]()
The call will end automatically after the specified duration [(3) ]() . This would handle your use case where a user calls for 2 minutes, hangs up, then calls again - you could set the second call to automatically end after the remaining 2 minutes.AI Evy
09/11/2025, 7:33 AMAI Evy
09/11/2025, 7:33 AMtrumliem
09/11/2025, 7:36 AMtrumliem
09/11/2025, 7:37 AMAI Evy
09/11/2025, 7:37 AMAI Evy
09/11/2025, 7:37 AMmax_call_duration_ms setting is configured at the agent level [(1) ]() [(2) ]() , which means all calls using that agent will have the same maximum duration limit.
According to the documentation, each agent within your plan can handle an unlimited number of calls simultaneously, provided you stay within your concurrency quota [(3) ]() . However, since max_call_duration_ms is an agent-level configuration [(1) ]() [(2) ]() , if you set it to 2 minutes for one user, any other user calling the same agent would also be limited to 2 minutes.
This means the static agent-level approach won't work for your use case where different users need different call duration limits. You would need a dynamic solution that can adjust call duration per individual call, which isn't directly supported through the agent configuration alone.
For your graduation project, you might need to implement this functionality at the application level - perhaps by programmatically ending calls through your webhook integration when a user reaches their time limit, rather than relying solely on the agent's max_call_duration_ms setting.AI Evy
09/11/2025, 7:37 AMAI Evy
09/11/2025, 7:37 AMtrumliem
09/11/2025, 7:54 AMAI Evy
09/11/2025, 7:54 AMAI Evy
09/11/2025, 7:54 AMend_call function that includes a message parameter for what the agent should say before ending the call .
Option 3: LLM WebSocket Response Events
Through the LLM WebSocket API, you can send response events that include an end_call boolean parameter [(3) ]() . When you set end_call to true in a response event, Retell will end the call after the content is fully spoken .
For your specific use case where you need to trigger call termination based on time limits, the LLM WebSocket approach would be most suitable. You could monitor call duration on your server and send a response event with end_call: true when a user reaches their time limit .
The key is that the LLM needs to intelligently decide when to call the end_call function based on the conversation context or external triggers you provide [(4) ]() .AI Evy
09/11/2025, 7:55 AMAI Evy
09/11/2025, 7:55 AMtrumliem
09/12/2025, 8:12 AMAI Evy
09/12/2025, 8:12 AMAI Evy
09/12/2025, 8:12 AMAI Evy
09/12/2025, 8:12 AMend_call parameter set to true [(1) ]() .
Here's how it works with the WebSocket:
Response Event Structure:
The RetellResponse object includes an end_call boolean parameter . When you set this to true, Retell will end the call after the content is spoken .
Example Implementation:
From the documentation, here's how you would structure the response to end a call [(2) ]() :
typescript
const res: RetellResponse = {
response_id: request.response_id,
content: funcCall.arguments.message,
content_complete: true,
end_call: true,
};
ws.send(JSON.stringify(res) ) ;
Key Points:
- You can send this response at any time during the call when you determine it should end [(1) ]()
- The agent will speak the content message before ending the call [(2) ]()
- This gives you full programmatic control over when calls terminate [(1) ]()
For your use case with time-limited packages, you could monitor call duration on your server and send a response event with end_call: true when a user reaches their time limit. This would work regardless of how many users are calling simultaneously, since each call gets its own WebSocket connection .AI Evy
09/12/2025, 8:12 AM