How can I end an ongoing call between a user and a...
# support
m
I am trying to find a way to end an ongoing call between a user and assistant in one click from my side or website or app whenever I want to. Is it even possible to do that?
@Sahil @Shubham Bajaj
v
@Mr Stark Yes, it is possible to end an ongoing call between a user and an assistant programmatically. This can typically be achieved by integrating a function into your website or app that sends a command to the voice API to terminate the call. The specific implementation would depend on the capabilities of the VAPI you are using. If you are looking to implement such a feature, you would need to refer to the API documentation for the specific endpoint or method that allows you to end calls. If you have access to the VAPI's functions, there might be a function like
end_call
or similar that you can call with the necessary parameters, such as the call ID. If you need assistance with the specific function call or implementation, please provide more details or ask for support from the VAPI provider for more info on this.
You can continue this conversation by mentioning me in the message.
m
@Vapi send me the link to the function in the docs I wasn't able to find anything like that in the docs
v
@Mr Stark Please ask support for more info on this.
Got it. Tagging @User for additional help.
m
where is the function end_call?
v
@Mr Stark Please ask support for more info on this.
s
you can do it using twiml. Twiml is twilio markup language. You have to search for call hangup using twilio/twiml and there is no docs available in Vapi.
But yeah it is doable.
m
@Shubham Bajaj To end a call on button click you mentioned using you can do it using twiml. Is there another way? Like maybe by injecting a key phrase like "oh, sorry gotta go!) into the convo which would trigger the bot to hang up when endCallFunctionEnabled = true? Also I'm looking at the twilioML doc here https://www.twilio.com/docs/voice/twiml/hangup and wondering if it would work for multiple simultaneous calls?
s
@Mistermanu#000 You can add end call phrases to your assistant which triggers the endCall function.
m
@Shubham Bajaj I do have the end call phrases but I want to end the call on button click from my user's dashboard so I was thinking either I manage to use twilioML or if I can't maybe an easier way is to just inject one of the end call phrases into the conversation? Refering to this: https://docs.vapi.ai/calls/call-features#example-injecting-a-message
s
@Mistermanu#000 You can use this example to first say something and then end the call. You can also end the call with add message but then it might the end call before saying the message.
Copy code
sh
#!/bin/bash
CALL_ID="7400d"
CONTROL_URL="https://aws-us-west-2-production1-phone-call-websocket.vapi.ai/$CALL_ID/control"

# 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"
}'
m
oh got it! Thanks for the help as usual!
25 Views