Graceful shutdown of phone call after x mins?
# support
m
Is it possible for the AI agent to have the context of how long it has been on the phone call for, and trigger a graceful end of the call (saying that it has to go now) rather than just abruptly ending the call at maximumDurationSeconds?
v
Yes, the Vapi Voice AI platform can manage call durations and trigger a graceful end to calls. While it doesn't explicitly track the duration of a call in real-time, it allows for a context-aware approach to call termination. You can program the AI agent to recognize when certain objectives are met during the conversation. When nearing the maximum duration, you can use the
say
method with the
endCallAfterSpoken
parameter set to
true
to provide a closing statement before ending the call. This way, the agent can inform the user that the call is about to end, ensuring a smoother transition rather than an abrupt cutoff. For example, you could set up a message like, "Your call will be ending soon. Is there anything else I can assist you with?" This can be scheduled to trigger just before the maximum duration is reached. If you need more details on how to implement this, feel free to ask! ๐Ÿ˜Š Sources: - [Vapi Call Management Features](https://docs.vapi.ai/calls/call-features) - [Graceful Call Termination](https://discord.com/channels/1211482211119796234/1211483291191083018/1336004944150401166) - [Configuring Vapi Voice AI Agents](https://discord.com/channels/1211482211119796234/1211483291191083018/1344633027925377064)
m
@Vapi Support Bot For my use case, there aren't set objectives. Unless the call recipient decides to hang up the call first, the call will go right up until the maxDurationSeconds and will end abruptly. Given this, I need to know what types of contexts (current duration of call would be best) are available to the agent such that it can decide to gracefully end the call. You said that "This can be scheduled to trigger just before the maximum duration is reached." How do you actually do that?
v
To gracefully end a call on the Vapi platform when there are no set objectives, you can implement a strategy that utilizes the
maxDurationSeconds
parameter effectively. While the platform does not provide real-time tracking of the call duration, you can set up a mechanism to trigger a warning message just before the maximum duration is reached. Hereโ€™s how you can do it: 1. **Set the Maximum Duration**: First, ensure that you have defined the
maxDurationSeconds
for your calls. This parameter determines how long a call can last before it is automatically terminated. 2. **Schedule a Warning Message**: You can use the
say
method to schedule a warning message that will be sent to the user shortly before the call ends. For example, if your maximum duration is set to 1800 seconds (30 minutes), you could schedule a warning to be sent at 29 minutes. Hereโ€™s a sample implementation:
Copy code
json
   {
     "actions": [
       {
         "say": "Your call will be ending in one minute. Is there anything else I can assist you with?",
         "endCallAfterSpoken": false
       }
     ]
   }
3. **Triggering the Warning**: You can programmatically determine when to send this warning based on the
maxDurationSeconds
. For instance, if you set a timer or a countdown in your application, you can trigger the warning message when the call duration reaches a certain threshold (e.g., 29 minutes). 4. **Graceful Call Termination**: After the warning message is delivered, you can then use the
say
method again with
endCallAfterSpoken
set to
true
to gracefully end the call after the user has had a chance to respond. By implementing this approach, you can ensure that the call does not end abruptly and that the user is informed before the call concludes. If you need further assistance with the implementation or have more questions, feel free to ask! ๐Ÿ˜Š Sources: - [Vapi Call Management Features](https://docs.vapi.ai/calls/call-features)
m
@Vapi Support Bot Okay the call control is very helpful. By the way, is there a way to update the metadata of the call using the call control? Or is the possible action that one can take through call control the "say" type? In fact, can you just tell me which actions are available via call control?
v
The Vapi Voice AI platform provides several actions that can be performed using call control, primarily focused on enhancing the interaction during live calls. Here are the key actions available: 1. **Injecting Conversation Elements**: You can use the
say
action to inject messages into the call. This allows you to communicate specific instructions or information dynamically during the conversation. For example:
Copy code
json
   {
     "actions": [
       {
         "say": "Welcome to Vapi, this message was injected during the call."
       }
     ]
   }
2. **Real-Time Audio Streaming**: The platform allows for streaming the call's audio data in real-time, which can be useful for monitoring or recording purposes. 3. **Event Hooks**: You can set up event hooks to trigger actions based on call events, such as when a call is ending. This allows for more complex interactions, like transferring calls or executing specific commands based on the call's status. Regarding updating call metadata, the documentation does not explicitly mention the ability to update metadata directly through call control. The focus is more on operational control and interaction during the call rather than modifying metadata. However, you can manage certain aspects of the call through the API, but it may not cover all metadata updates. If you have any specific use cases in mind or need further clarification, feel free to ask! ๐Ÿ˜Š Sources: - [Detailed Report on Call Control Actions in the Vapi Voice AI Platform](https://docs.vapi.ai/calls/call-features) - [Vapi Call Management Features](https://docs.vapi.ai/calls/call-features) - [Event Hooks in Vapi](https://docs.vapi.ai/changelog/2025/2/17)
k
Hey @markqloagan, checking if this is resolved for you.