Skip to content

Hangup Action

End the call.

Action Structure

json
{
  "type": "hangup",
  "session_id": "550e8400-e29b-41d4-a716-446655440000"
}

Fields

FieldTypeRequiredDescription
typestringYesAlways "hangup"
session_idstring (UUID)YesSession identifier from event

Examples

Python

python
@app.route('/webhook', methods=['POST'])
def webhook():
    event = request.json

    if event['type'] == 'user_speak':
        user_text = event['text'].lower()

        if 'goodbye' in user_text or 'bye' in user_text:
            return jsonify({
                'type': 'hangup',
                'session_id': event['session']['id']
            })

Node.js

javascript
app.post('/webhook', (req, res) => {
  const event = req.body;

  if (event.type === 'user_speak') {
    const userText = event.text.toLowerCase();

    if (userText.includes('goodbye') || userText.includes('bye')) {
      return res.json({
        type: 'hangup',
        session_id: event.session.id
      });
    }
  }
});

Go

go
if strings.Contains(text, "goodbye") || strings.Contains(text, "bye") {
    action := map[string]interface{}{
        "type":       "hangup",
        "session_id": session["id"],
    }
    json.NewEncoder(w).Encode(action)
}

Use Cases

  • User says goodbye - End call politely
  • Task complete - After completing a task
  • Error handling - When something goes wrong
  • Timeout - After inactivity

Best Practices

  1. Say goodbye first - Optionally speak before hanging up
  2. Clean up state - Session will end, but cleanup in session_end
  3. Log the reason - Track why calls ended
  4. Handle gracefully - Don't hang up abruptly

Next Steps