End-call function via api - can't find where to in...
# support
s
How can I from the API side of things be able to have the assistant say a certain message when ending the call? Is it request complete message, request -start? Or is there a different parameter for that message to be spoken. Thanks! https://cdn.discordapp.com/attachments/1364253373980737601/1364253374362685500/image.png?ex=6808ff77&is=6807adf7&hm=cc3264166cab3e2c3644a8a9fd8594465c59702fdd9cdfc27aecb54c6c402bc7&
v
Hi there! 👋 I don't have specific confirmation that "request complete message" or "request-start" are the correct parameters for the end call message, but I can definitely help with how to configure the assistant's last message when ending a call via the API! Based on the information I found, here are several ways to achieve this: ### 1. Using the
add-message
type via API The most direct way is to send a message before ending the call using the
add-message
type:
Copy code
sh
# First send the message
curl -X POST "https://aws-us-west-2-production1-phone-call-websocket.vapi.ai/$CALL_ID/control" \
-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 "https://aws-us-west-2-production1-phone-call-websocket.vapi.ai/$CALL_ID/control" \
-H 'content-type: application/json' \
--data-raw '{
  "type": "end-call"
}'
This approach ensures the message is spoken before the call ends, as mentioned in the [documentation](https://discord.com/channels/1211482211119796234/1296705973737488505). ### 2. Using the
endCallMessage
parameter The
endCallMessage
parameter defines the message the assistant will speak when it decides to end the call, as noted in the [outbound sales documentation](https://docs.vapi.ai/examples/outbound-sales). ### 3. Using the
say
method with
endCallAfterSpoken
You can use the
say
method with the
endCallAfterSpoken
parameter set to
true
to gracefully end the call after a message is spoken:
Copy code
json
{
  "say": "Thank you for your time. Goodbye!",
  "endCallAfterSpoken": true
}
This requires implementing logic to detect when objectives are met and then triggering the
say
method, as mentioned in the [documentation](https://discord.com/channels/1211482211119796234/1336004944150401166).
### 4. Using the
messages
list in the
endCall
object Looking at your attached image, you can see that the
endCall
object includes a
messages
list. This list can contain objects that define messages to be spoken while the tool is running. You can customize these messages for the
endCall
tool. For example, similar to how the "voicemail" tool uses a "request-complete" message:
Copy code
json
"messages": [
  {
    "type": "request-complete",
    "content": "Thank you for your time. Goodbye!",
    "endCallAfterSpokenEnabled": true
  }
]
Is there anything specific about these methods you'd like me to elaborate on? Sources: - [Discord: Using the
say
method with
endCallAfterSpoken
](https://discord.com/channels/1211482211119796234/1336004944150401166) - [Vapi Documentation: Outbound Sales Example](https://docs.vapi.ai/examples/outbound-sales) - [Discord: Using
add-message
via API](https://discord.com/channels/1211482211119796234/1296705973737488505) - [Discord: Voicemail tool example with messages list](https://discord.com/channels/1211482211119796234/1336548894896816222)
s
@Shubham Bajaj @Mason anyone?
s
looking into it.
@SlaviSavanovic You can use request complete message.Let me know how it goes for you.
s
Okay will do. Thank you. Will let you know the result soon. Also, sesame voice is not producing audio, down on vapi landing page and not working in vapi dashboard
request-complete did it. thank you @Shubham Bajaj
k
Hey Slavi, could you please create a new ticket for sesame voice not working?
2 Views