OpenAPI 3.1.0MITraw.githubusercontent.com2026-08-132528872.0 MB

91fbe575ddf9

AI Webhooks

AI debug webhook

A diagnostic feed for a call that is still in progress. Set debug_webhook_url on your agent and every step it takes is posted to that URL as it happens: speech recognized, model called, tool invoked, context switched, error hit. Use it to work out why a call went the way it did — which tool the agent reached for, what came back, where a turn went wrong — or to react while the call is still live, such as paging a supervisor.

Each request carries call_info plus one or more event properties, where the property name is the event. One moment can produce several: evaluating a data_map webhook sends webhook, input, output, error_keys, and match together. Handle the properties you recognize and ignore the rest, since the set grows over time.

Setting the URL is what enables the feed. debug_webhook_level only widens it: at 2 it also carries conversation_add, llm_request, and llm_response, which fire on every turn and every model call.

postWebhookaiDebugWebhook

Payload

process_actionobject

A tool returned a SWAIG action. Carries the action exactly as your endpoint returned it.

webhookobject

The webhook definition as you wrote it. Arrives alongside input, and alongside output and match when the call produced a reply, or error when the definition was unusable.

inputobject

The body sent to the webhook, or the input an output template was expanded against.

outputobject nullable

The reply the webhook produced, or the output template that matched. null when nothing matched.

matchobject nullable

The entry that matched. null when none did.

expressionobject

The expressions entry as you wrote it. Arrives alongside input and output.

webhook_replyobject nullable

The final reply the webhook produced, after matching. An array reply is wrapped as { "array": [...] }. null when the webhook produced no reply.

Example payload

{
  "call_info": {
    "project_id": "4d0d6f16-5881-4fcc-92a4-02c51a91954d",
    "space_id": "451ed9ff-e568-4222-8af9-4f9ab7428d09",
    "call_id": "2e1e66e5-5d07-413d-9668-55542992eec0",
    "content_type": "text/json",
    "content_disposition": "post_data",
    "conversation_type": "voice"
  },
  "session_start": {
    "model": "gpt-4.1-mini",
    "tts_engine": "elevenlabs",
    "tts_voice": "rachel",
    "language": "en-US",
    "mode": "oart",
    "rate": 24000,
    "audio_format": "pcm16",
    "tool_model": "gpt-4.1-mini",
    "local_vad": true
  },
  "session_end": {
    "reason": "normal",
    "ended_by": "assistant",
    "duration_ms": 37651,
    "input_tokens": 5627,
    "output_tokens": 119
  },
  "startup_hook": {
    "duration_ms": 214,
    "success": true,
    "error": "execution failed"
  },
  "hangup_hook": {
    "duration_ms": 186,
    "success": true,
    "error": "execution failed"
  },
  "speech_detect": {
    "text": "I need a ride to the airport.",
    "source": "final"
  },
  "barge": {
    "barge_type": "normal",
    "barge_elapsed_ms": 1240,
    "interrupt_count": 2,
    "audio_played_ms": 1240,
    "barge_count": 2
  },
  "ai_completion": {
    "type": "normal"
  },
  "filler": {
    "text": "Let me check on that.",
    "filler_type": "function"
  },
  "attention_timeout": {
    "timeout_ms": 15000
  },
  "hold": {
    "event": "hold",
    "timeout": 30
  },
  "function_call": {
    "function": "get_weather",
    "duration_ms": 412,
    "shadow": true,
    "phase": "post_prompt"
  },
  "function_loop": {
    "function": "get_weather",
    "type": "repeated",
    "count": 3
  },
  "swaig_call": {
    "command_name": "get_weather",
    "command_arg": "{\"city\":\"San Francisco\"}",
    "epoch_time": 1694541334,
    "native": true,
    "url": "https://example.com/tools/get_weather",
    "mcp_error": true
  },
  "tool_distill": {
    "function": "get_weather",
    "raw_chars": 8412,
    "distilled_chars": 612,
    "model": "gpt-4.1-mini"
  },
  "error": {
    "error": "ai: webhook error",
    "errorText": "Webhook obj must have output or expressions"
  },
  "webhook_log": {
    "request_url": "https://example.com/weather?city=Springfield"
  },
  "webhook_fail": {
    "call_info": {
      "project_id": "4d0d6f16-5881-4fcc-92a4-02c51a91954d",
      "space_id": "451ed9ff-e568-4222-8af9-4f9ab7428d09",
      "call_id": "2e1e66e5-5d07-413d-9668-55542992eec0",
      "content_type": "text/json",
      "content_disposition": "post_data",
      "conversation_type": "voice"
    },
    "error": "webhook error",
    "request_url": "https://example.com/tools/get_weather",
    "attempts": 3,
    "parse_error": true,
    "protocol_error": true,
    "curl_code": 28,
    "http_code": 502
  },
  "step_change": {
    "from_step": "greet",
    "to_step": "collect_address",
    "to_index": 1,
    "trigger": "ai_function"
  },
  "context_change": {
    "to_context": "billing",
    "from_context": "default",
    "trigger": "ai_function"
  },
  "gather_start": {
    "context": "default",
    "step": "collect_address",
    "step_index": 2,
    "output_key": "address",
    "total_questions": 3
  },
  "gather_question": {
    "context": "default",
    "step": "collect_address",
    "step_index": 2,
    "key": "street",
    "question_type": "string",
    "requires_confirm": true
  },
  "gather_answer": {
    "context": "default",
    "step": "collect_address",
    "step_index": 2,
    "key": "street",
    "confirmed": true
  },
  "gather_reject": {
    "context": "default",
    "step": "collect_address",
    "step_index": 2,
    "key": "street",
    "reason": "missing_answer"
  },
  "gather_complete": {
    "context": "default",
    "step": "collect_address",
    "step_index": 2,
    "output_key": "address",
    "answered": 3,
    "completion_action": "next_step"
  },
  "conversation_add": {
    "role": "assistant",
    "content": "Your ride is booked for 6pm.",
    "lang": "en-US",
    "tokens": 53,
    "timestamp": 1694541297950440
  },
  "llm_request": {
    "model": "gpt-4.1-mini",
    "prompt_tokens": 412,
    "conversation_tokens": 5215
  },
  "llm_response": {
    "model": "gpt-4.1-mini",
    "output_tokens": 53,
    "duration_ms": 836,
    "success": true
  },
  "llm_error": {
    "event": "llm_retry",
    "model": "gpt-4.1-mini",
    "token_count": 128000,
    "limit": 120000,
    "errors": 4,
    "reasoning_effort": "high"
  },
  "consolidation": {
    "event": "consolidation",
    "token_count": 121400,
    "limit": 120000
  },
  "summarize_start": {
    "mode": "function",
    "model": "gpt-4.1-mini"
  },
  "post_prompt": {
    "url": "https://example.com/reports"
  },
  "text_normalize": {
    "direction": "itn",
    "language": "en",
    "original": "twenty twenty six",
    "normalized": "2026"
  },
  "voice_error": {
    "event": "voice_config_error",
    "engine": "elevenlabs",
    "voice": "rachel",
    "fallback_engine": "gcloud",
    "fallback_voice": "en-US-Neural2-J"
  },
  "warning": {
    "event": "excessive_prompt_tokens",
    "tokens": 82000
  },
  "oart_user_transcript": {
    "text": "I need a ride to the airport."
  },
  "oart_assistant_transcript": {
    "text": "Your ride is booked for 6pm."
  },
  "oart_response_done": {
    "latency": 836,
    "utterance_latency": 934,
    "audio_latency": 1106,
    "acoustic_latency": 1180,
    "status": "completed"
  },
  "inner_dialog": {
    "text": "The caller has not given a pickup address yet."
  }
}

Response

Webhook received