https://retellai.com/?utm_source=discord&utm_medium=seo logo
I have an important question: Can I manually end a...
# ❓・ai-evy-support
t
@AI Evy I have an important question: Can I manually end a phone call in Retell? For my graduation project, I’m integrating Retell and need to test how it works. The idea is that I sell a package that allows a user to call Retell for 4 minutes. For example, if the user calls for 2 minutes and hangs up, then makes another call, I need a way to automatically end the call once they reach the remaining 2 minutes. Can Retell support this use case?
a
Thanks for tagging me @trumliem. I'll look through relevant sources and get back to you shortly.
### Answer Yes, Retell AI can support your use case. The platform provides a
max_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.
​ To learn more, see the sources I considered: [[1] Update Agent](https://docs.retellai.com/api-references/update-agent) [[2] List Agents](https://docs.retellai.com/api-references/list-agents) [[3] Understand concurrency & limits](https://docs.retellai.com/deploy/concurrency) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@User But is this work correctly ? Because i have only one agent and if i setting it Max call duration is 2 minutes and at that time an another user start call ant this user have 5 minutes what wil hapen ?
@AI Evy But is this work correctly ? Because i have only one agent and if i setting it Max call duration is 2 minutes and at that time an another user start call ant this user have 5 minutes what wil hapen ?
a
Thanks for the follow-up, @trumliem. I'll get back to you soon.
### Answer You're correct to question this approach. The
max_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.
​ To learn more, see the sources I considered: [[1] Update Agent](https://docs.retellai.com/api-references/update-agent) [[2] Create Agent](https://docs.retellai.com/api-references/create-agent) [[3] Understand concurrency & limits](https://docs.retellai.com/deploy/concurrency) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@AI Evy is during the call process, can I insert a message or json to say "Please hang up the call"? Because I see that Retell has a place to set up a call function, but I don't know if I can insert the end_call part so that the function can receive it or not, like a trigger function so that I can hang up the call.
a
Thanks for the follow-up, @trumliem. I'll get back to you soon.
### Answer ### Answer Yes, you can trigger a call to end during the call process using Retell AI's function calling mechanism. There are several ways to accomplish this: Option 1: End Call Tool Configuration You can configure the agent to end calls automatically by adding the End Call tool [(1) ]() . In the tools section, click "+ Add" and select "End Call" from the dropdown menu . Then define specific conditions under which the call should be terminated, such as "If the user says 'thank you', 'goodbye', or 'bye', use the end_call tool to terminate the conversation" . Option 2: Custom LLM with Function Calling For more programmatic control, you can implement function calling with a custom LLM [(2) ]() . You would define an
end_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) ](

▾

) .
​ To learn more, see the sources I considered: [[1] End call](https://docs.retellai.com/build/single-multi-prompt/end-call) [[2] Integrate Function Calling](https://docs.retellai.com/integrate-llm/integrate-function-calling) [[3] LLM WebSocket](https://docs.retellai.com/api-references/llm-websocket) [[4] How to use function calling to end the call in Retell AI](

https://www.youtube.com/watch?v=9qyML06RiT0▾

) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@AI Evy So if i use Web Socket i can custom an end call by interact with an end_call function on Retell right ?
a
Thanks for the follow-up, @trumliem. I'll get back to you soon.
​ To learn more, see the sources I considered: [[1] LLM WebSocket](https://docs.retellai.com/api-references/llm-websocket) [[2] Integrate Function Calling](https://docs.retellai.com/integrate-llm/integrate-function-calling) ​
### Answer Yes, exactly! When using the LLM WebSocket, you can programmatically end calls by sending a response event with the
end_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) ]() :
Copy code
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 .
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.