Skip to main content

Overview

The hook system lets you register async handlers that fire at specific points in a call’s lifecycle. There are two levels of hooks:
  • Runner-level - fire for every call the runner handles (e.g. logging, metrics)
  • Session-level - fire on events within a single call (e.g. per-turn logic, silence detection)

Registering Hooks

Decorator style


Runner-Level Events

These fire at the runner level - once per call, regardless of what happens inside the session. final_state values: "ended", "failed"

Session-Level Events

Registered with @ctx.session.on(event) inside your entrypoint. These fire during session.run().

call_start

Fires at the very beginning of the session loop, before any events are processed:

user_turn

Fires when the user has finished speaking and the transcription is ready:

agent_turn

Fires after the agent’s full reply has been generated (post-streaming):

interruption

Fires when the user interrupts the agent mid-utterance:

call_end

Fires when the session loop exits (call hung up, error, or session.end() called):

Complete Hook Reference


Multiple Hooks for the Same Event

You can register multiple handlers for the same event - all are called in registration order:

Practical Patterns

Silence detection with timeout

CRM enrichment at call start

Escalation trigger

Full call logging


Next Steps

Outbound Calls

Initiate calls programmatically from your backend.

Session Controls

Use say, transfer, end, and recording controls.