The endCall function does not work
# support
e
We are trying to make the agent hang up the call when necessary. The flag is active in the agent's configuration via VAPI, and we have the function included in the API context as follows: model: { provider: 'openai', model: 'gpt-4o', messages: [ { role: 'system', content: systemPrompt, }, ], tools: [{ type: 'voicemail' }, { type: 'endCall' }], }, However, the agent simply does not hang up the call, even when it plays the closing message or when it reaches a situation where the call should be ended according to the instructions. Can someone help us?
v
Hi Eric! 👋 I see you're having trouble with the
endCall
function not working properly. Let's troubleshoot this issue: First, I can see you've correctly included the
endCall
tool in your tools array, which is good! Here are some things to check: 1. **Dashboard Configuration**: Ensure the
endCallFunctionEnabled
parameter is set to
true
in the VAPI dashboard [(source)](https://discord.com/channels/1211482211119796234/1211483291191083018/1313293840580612166). 2. **Function Parameters**: Verify that the
endCall
function is being called with the correct parameters:
Copy code
json
   {
     "callId": "your-call-id",
     "reason": "Call completed",
     "timestamp": "YYYY-MM-DDTHH:MM:SSZ"
   }
[(source)](https://discord.com/channels/1211482211119796234/1211483291191083018/1305929557144240159) 3. **Trigger Implementation**: Make sure you're properly triggering the function in your code. Consider adding explicit triggers like detecting when a user says "goodbye" [(source)](https://discord.com/channels/1211482211119796234/1211483291191083018/1313293840580612166). 4. **Idle Messages**: Configure idle messages to detect when the user is silent for a few seconds, which can trigger the call end [(source)](https://discord.com/channels/1211482211119796234/1211483291191083018/1313293840580612166). 5. **Network/API Issues**: There might be network or API issues causing unreliability in call terminations. Check your logs for any error messages [(source)](https://discord.com/channels/1211482211119796234/1211483291191083018/1305929557144240159). 6. **Implementation Logic**: Review your code to ensure the function is triggered at the correct point in your logic and that all questions have been answered before calling it [(source)](https://discord.com/channels/1211482211119796234/1211483291191083018/1305929557144240159). Let me know if any of these steps help resolve the issue or if you need more specific guidance! Sources:
e
@Vapi @Shubham Bajaj
k
Copy code
markdown
Your agent has the `endCall` tool configured in its settings, but it's not actively invoking the tool when it should hang up the call. This happens because:

1. The model needs to be explicitly instructed to use the `endCall` tool in the system prompt
2. The agent needs to know exactly when it should end the call

## The Solution

You need to update your system prompt to include explicit instructions about when and how to use the `endCall` tool. Here's how you should modify your setup:

1. Update your system prompt to include clear instructions about ending the call, including:
   - When to end the call (specific scenarios)
   - How to properly invoke the `endCall` tool

2. The format for calling the endCall tool should be included in the agent's response like this:
I'll help you with that. [Conversation content] Now that we've completed our conversation, I'll end the call. { "tools": [ { "type": "endCall", } ] }
Copy code
In your systemPrompt, add instructions like these:
[Your existing prompt content] IMPORTANT: When the conversation should end, such as after providing final information, answering the last question, or when the caller explicitly wants to end the call, you MUST use the endCall tool to hang up.
Copy code
Make sure to clearly define scenarios when the call should end, such as:
- When the caller explicitly asks to end the call
- After delivering the requested information if no follow-up is needed
- When all tasks have been completed
e
@andmac
3 Views