N3squik
03/22/2025, 11:59 AMendCall
function being called with arguments. I cannot find a way to not call it without any. The behaviour I want is to respond with a message and then call endCall
, instead of it passing the message as arguments to endCall
and calling the function.
I have tried to tell it via prompt engineering instruction but no success. Here is an example call id it happens in - e5a374f5-f4d1-4368-8fc3-e59f38b75920
Vapi Support Bot
03/22/2025, 12:01 PMendCall
function being called with arguments when you want it to be called without any. While I can't access the specific details of the call ID you provided, I can definitely help with approaches to solve this issue.
Here are several methods to call endCall
without arguments:
### Method 1: Use the end-call
message type
You can programmatically end a call by sending an end-call
message type within `ClientInboundMessage`:
sh
curl -X POST "https://aws-us-west-2-production1-phone-call-websocket.vapi.ai/YOUR_CALL_ID/control" \
-H 'content-type: application/json' \
--data-raw '{
"type": "end-call"
}'
### Method 2: Use separate message types
You can first send a message with add-message
type and then end the call with end-call
type:
sh
# First send the message
curl -X POST "$CONTROL_URL" \
-H 'content-type: application/json' \
--data-raw '{
"type": "add-message",
"message": {
"role": "assistant",
"content": "Thank you for your time. I will end this call now. Goodbye!"
},
"triggerResponseEnabled": true
}'
# Wait for message to be spoken
sleep 2
# Then end the call
curl -X POST "$CONTROL_URL" \
-H 'content-type: application/json' \
--data-raw '{
"type": "end-call"
}'
### Method 3: Use the endCallAfterSpoken
parameter
You can use the say
method with the endCallAfterSpoken
parameter set to `true`:
javascript
// This will speak the message and then end the call
say("Thank you for your time. Goodbye!", { endCallAfterSpoken: true });
### Prompt Engineering Approaches
If you're still having issues, try these prompt engineering techniques:
1. Provide clear instructions: "After saying goodbye, trigger the endCall function without any arguments"
2. Try using: Say: "GoodBye" and trigger the endCall function
3. Add to your user prompt: [Call Hangup Conditions] If user says 'goodbye' or anything similar to it then trigger the endCall function
Vapi Support Bot
03/22/2025, 12:01 PMendCall
function in Vapi, including:
- The function not receiving the correct parameters
- Calls ending for "unknown reasons"
- The "End Call Function" not working as expected
Is there a specific approach from these that you'd like me to elaborate on further?
Sources:
- [Using the end-call
message type](https://docs.vapi.ai/changelog/2025/1/14)
- [Using add-message
and end-call
message types](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1296705973737488505)
- [Using the endCallAfterSpoken
parameter](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336004944150401166)
- [Alternative Prompt Engineering Techniques](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1313293840580612166)
- [Issues with endCall
function](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1305929557144240159)N3squik
03/22/2025, 5:21 PMendCall
, e.g. leave a voicemail message.Kyle
03/24/2025, 2:09 PMCall Termination Instructions:
- When it's time to end the call:
Say: <message> and trigger the endCall tool.
This dedicated section ensures that all instructions leading to the call ending are handled first (the message is delivered as plain text) and only then is the endCall function executed with no parameters.
Let me know how it goes for you.N3squik
03/26/2025, 12:26 PM1af0acda-0a41-4d57-bd4a-944c49a195be
.
Shouldnt there be a way on Vapi to define endCall
with strict params and define no params %{}
so they are not going to be get called.Kyle
03/29/2025, 7:44 AMstrict
set to true
. Just that you have to create a custom end call function whose type is set to end call, and I'll suggest naming it CustomEnd Call
so that it doesn't collapse with the built-in function. This way, the probable chances of your tool call calling with parameters will be sorted out.N3squik
04/02/2025, 1:14 PMYou are a helpful assistant.
Call Termination Instructions:
- When it's time to end the call say: "Thank you for calling. Goodbye." and trigger the endCall tool.
Important: Each round you first answer the user. At the very end of your response, you invoke any function call. Never say that you will trigger it.
With the new text chat window, I was able to test and correctly see the behaviour. As seen on the screenshot, AI does the text response and then calls endCall.
However, when voice calling it does not do it. Now I do get a different behaviour, AI gets in the middle of saying goodbye message, when it then gets cut off by its own end call tool call (example call id - "40b236f2-7259-4429-89a2-f7d0b1096d50"). The goodbye message is not displayed in the logs either. I think there is a racing condition happening here, AI does not have enough time to convert text to speech and output it, before the endCall tool is processed by Vapi. This seems like a bug on Vapi side.
https://cdn.discordapp.com/attachments/1352975076584067185/1356980137593147403/image.png?ex=67ee89bc&is=67ed383c&hm=9a367c8d770054f2a615d7ff9c7a7335fd6c19437d1d47cf375a743b338cd2f6&Kyle
04/06/2025, 12:37 PMN3squik
04/09/2025, 4:26 PMKyle
04/11/2025, 1:10 AMšµ 13:12:33:698 Converted Requested Tools Calls To Internal Format. [
{
"type": "endCall",
"function": {"name": "endCall", "description": "End the call."},
"messages": [
{
"type": "request-start",
"content": "",
"contents": [],
"conditions": [],
"blocking": false
}
],
"toolCall": {
"id": "call_aCMbpmrQIF0Bm6oZRMFJOh2k",
"type": "function",
"function": {"name": "endCall", "arguments": {}},
"isPrecededByText": true
}
}
]
Kyle
04/11/2025, 1:18 AMKyle
04/11/2025, 1:19 AMN3squik
05/01/2025, 5:41 PM