endCall without arguments
# support
n
Hi, I am have an issue with
endCall
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
v
Hi there! šŸ‘‹ I understand you're having trouble with the
endCall
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`:
Copy code
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:
Copy code
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`:
Copy code
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
### Known Issues There are known issues with the
endCall
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)
n
The problem is that it cannot respond with a normal message and then call
endCall
, e.g. leave a voicemail message.
k
Copy code
Call 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.
n
@Shubham Bajaj No I still get the same issue, I have tried several prompt engineering techniques but no luck. Here is an example call id where is still happens -
1af0acda-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.
I also notice that AI is saying they will hang up, but do not and are stuck waiting for the user to reply. On user replying, only then AI is calling
endCall
tool. For example, AI: ... I will check with him and call you back. Thank you. User: Okay thank you AI:
endCall
call
k
Okay, I looked into your call ID again, and honestly speaking, it's a pure prompting problem as of now. You can create an end call function with
strict
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.
n
@Shubham Bajaj Thank you for the suggestion. To understand if this is actually a prompt engineering issue, I have created a simple prompt that literally only has end call instruction like this -
Copy code
You 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&
k
Hi, checking if this is resolved/solved for you?
n
@Shubham Bajaj Nope, I was hoping you could raise with your techincal team since it looks like a bug on Vapi.
k
Copy code
šŸ”µ 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
    }
  }
]
Yes, you are right. This is on us. What else you can do is you can set the assistant endCall message, and when the end call tool is triggered, this message will be voiced out. As of now, I know that the text tool called "preceded by text" is not working as expected, but this thing works because once you trigger the end call, then the end call message gets voiced out. The pipeline follows here the steps or the order of execution: tool called, then message compared to message and tool call.
1. You can configure your end call message in the Advanced tab of the Assistant editor 2. When you trigger the end call tool, that message will be spoken before ending the call 3. If you haven't configured an end call message, the system will default to "Goodbye" in the user's language 4.
n
@Shubham Bajaj Thank you for the suggestion. The problem is that my end message is dynamic, I want AI to insert specific values in the end call message (e.g. "Goodbye {username}"), so it would not work. Is this something Vapi dev team will be looking to fix in the near future or not?
k
curl -X PATCH \\ -H "Authorization: Bearer " \\ -H "Content-Type: application/json" \\ -d '{ "endCallPhrases": \[ "you can pass the end call phrase dynamically here" \] }' You can use either transient assistant or assistant overrides.
6 Views