Gracefully end the call with maxDuration settings
# support
a
I want to end the call with maxDuration settings. For example, if I set it to 2 minutes, after two minutes whatever the user says, it will ends the call or maybe transfer the call if possible.
v
To gracefully end a call after a set duration (e.g., 2 minutes), use the
maxDurationSeconds
property in your call configuration. Here’s a sample snippet:
Copy code
json
{
  "maxDurationSeconds": 120
}
This will automatically end the call after 2 minutes, regardless of user input. Note: Automatic transfer after max duration is not directly supported in the found documentation. [Reference](https://docs.vapi.ai/calls/assistant-based-warm-transfer#transfer-assistant-properties) Source: - [Assistant-based warm transfer](https://docs.vapi.ai/calls/assistant-based-warm-transfer#transfer-assistant-properties)
c
Hi Ahmer, you can use a combination of
maxDuration
setting and hooks to handle call duration limits. 1. First, set the
maxDuration
for the call [1](https://docs.vapi.ai/assistants/assistant-hooks):
Copy code
{  "maxDurationSeconds": 120  // 2 minutes}
2. Then, you can use
call.ending
hooks to handle the timeout gracefully :
Copy code
{
  "hooks": [
    {
      "on": "call.ending",
      "filters": [
        {
          "type": "oneOf",
          "key": "call.endedReason",
          "oneOf": [
            "exceeded-max-duration"
          ]
        }
      ],
      "do": [
        {
          "type": "say",
          "exact": "I apologize, but our time limit has been reached. I'll transfer you to a representative."
        },
        {
          "type": "tool",
          "tool": {
            "type": "transferCall",
            "destinations": [
              {
                "type": "number",
                "number": "+1234567890",
                "callerId": "+1987654321"
              }
            ]
          }
        }
      ]
    }
  ]
}
The call will automatically end after the specified duration, and you can either: - Simply end the call - Transfer to another number - Speak a message before ending - Combine multiple actions
a
Thanks @User
2 Views