About ending call based on call duration.
# support
y
Hi, I don't want him to exceed the total call time I set. For example, when he reaches the second minute, I want him to say his last sentence and end the call. I can detect the call time, but I want him to intervene and say his last closing sentence and end the call. How can I do it?
v
@Yavuz Kömeçoğlu To ensure that the call ends after a specific duration, such as two minutes, you can implement a timer within your voice application that starts at the beginning of the call. Once the timer approaches the two-minute mark, you can trigger your voice assistant to say the closing sentence and then end the call. Here's a general approach you can take: 1. Start a timer when the call begins. 2. Monitor the elapsed call time. 3. As the call time nears two minutes, prepare the closing sentence. 4. Have the voice assistant say the closing sentence. 5. End the call immediately after the closing sentence is delivered. If you're using a specific API or platform, there may be built-in functions or settings that can help you manage call time and automate the process of ending the call. If you provide more details about the tools or platform you're using, I can give you a more specific solution. Would you like to proceed with setting up such a feature, and if so, could you provide more details about your current setup?
You can continue this conversation by mentioning me in the message.
y
@Vapi Great. How can I trigger the closing statement with the API and also end the call?
v
@Yavuz Kömeçoğlu To trigger a closing statement and end the call using the Voice API, you would typically follow these steps: 1. **Set up a call timer**: When the call starts, begin a countdown timer for the desired duration (e.g., two minutes). 2. **Monitor the call duration**: Continuously check the elapsed time against the countdown timer. 3. **Prepare the closing statement**: As the timer approaches the end, prepare the closing statement that the voice assistant should say. 4. **Deliver the closing statement**: Use the Voice API to make the voice assistant say the closing statement. 5. **End the call**: After the closing statement is delivered, use the Voice API to end the call. The exact implementation details will depend on the Voice API you are using. Most Voice APIs have methods to play audio or text-to-speech and to disconnect the call. You would need to call these methods at the appropriate time. For example, if you are using a hypothetical
say
method to speak and an
endCall
method to end the call, you might have code that looks like this:
Copy code
javascript
if (callDuration >= 120) { // When the call duration reaches 2 minutes
  say("Thank you for calling, have a great day!"); // Trigger the closing statement
  endCall(); // End the call
}
Please note that the actual method names (
say
and
endCall
) and how you monitor the call duration (
callDuration >= 120
) will depend on the specific Voice API you are using. If you need assistance with a specific Voice API or if you have any other questions, please let me know!
y
@Vapi Which API can I use as an API reference? I work with the C# dotnet programming language.
s
what you can do is hangup the cal using twilio and twilioCallSid. 1. make vapi call your server url get the call object from request payload 2. after 2 minutes end the call by yourself 3. now main thing intervene from external trigger is not possible as of now, the bad option is tool call after each senetence.
y
We can end the call, but we don't want to close it directly without making the final closing statement. With the LLM model, instructions via the prompt cannot end it completely because they are not aware of the duration. But it would be nice if it could be done while the call is in progress, like the web sdk above, say this sentence and then close it.
The MaxDuration value also ends the call automatically, as you said.
s
yeah that's not possible instead can add the end call message at max.
y
Thanks.
10 Views