Overview
The hook system lets you registerasync 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.| Event | Arguments | When |
|---|---|---|
call_start | ctx: CallContext | Call dispatched and bridge connected |
call_end | ctx: CallContext, final_state: str | Call finished (any reason) |
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
| Scope | Event | Arguments | Description |
|---|---|---|---|
| Runner | call_start | ctx: CallContext | Call dispatched to this runner |
| Runner | call_end | ctx: CallContext, state: str | Call finished |
| Session | call_start | (none) | Session loop started |
| Session | user_turn | text: str | User utterance transcribed |
| Session | agent_turn | text: str | Full agent reply generated |
| Session | interruption | (none) | User interrupted agent |
| Session | call_end | state: str | Session loop exited |
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.