You use one identifier throughout: the
sid (call_sid). The engine mints
it once — at the inbound INVITE or when you call originate(). After that,
the sid addresses everything: audio, transfer, hangup, recording,
telemetry. You never mint a second one.What you’ll assemble
A call
Originate outbound over a SIP trunk. Or answer an inbound call that your
dialplan routes.
An agent
A server-side runtime that transcribes, reasons, speaks, and stops when
interrupted. You attach it to the call by id.
A safety net
Tools, a warm human handoff, and both-leg recording. A production agent
cannot ship without these.
Before you start
1
Provision a workspace
Choose managed cloud or self-hosted. Both give you a tenant with an API key
and a per-tenant SIP subdomain. See
managed cloud or
on-prem.
2
Configure a SIP trunk
A trunk carries calls to and from a carrier. Note its
trunkId. See
SIP trunking.3
Define an agent
An agent is a runtime config: a pipeline plus turn detection and tools.
Author it in the agent console or by
config. Note its
agent id. The shape is covered in
runtime overview.4
Initialize the Voice client
Step 1 — Get a call
You either start a call (outbound) or answer one that arrives (inbound). Both end with a livesid. You can attach an agent to that sid.
- Originate (outbound)
- Answer (inbound)
This is one control-plane call. Pass the agent id, and the engine attaches
the agent automatically at the moment the callee answers. Then you can skip
Step 2 entirely.
Step 2 — Attach the agent
Maybe you did not passagent to originate. Or you answer inbound from code
and want to bind an agent yourself. In both cases, attach an agent to the live
sid. The engine wires the audio bridge end to end: caller audio into the
agent, and agent audio back to the caller. You do not open a bridge yourself.
An attach binds a server-side agent. The agent runs inside the voice
gateway, on the core that owns the call’s media. Thus turn detection and
barge-in are wired straight into the media path. You may instead want to run
your own runtime and drive raw audio frames yourself. In that case, open an
AudioBridge and feed it. Or bring an
external runtime via
keep your existing runtime.Step 3 — Configure turn detection
Turn detection makes the call feel human. The agent stops the instant the caller talks (barge-in). The agent replies the instant the caller finishes. Turn detection lives in the agent config, not in your call code. Set it once per agent. Pick a mode. Cascaded pipelines use on-device VAD. Realtime models let the provider own turns."silero" | "server_vad"
default:"\"silero\""
silero runs on-device VAD in the gateway. It is the default for cascaded
ASR → LLM → TTS. server_vad lets a realtime provider own turn signalling.
A REALTIME entry node auto-promotes to server_vad unless you set type
explicitly.number
default:"500"
Trailing silence before end-of-utterance fires. Lower it (~300) for faster
replies. Raise it (~800) for callers who pause to think.
number
default:"300"
Minimum speech duration to count as a real utterance. Raise it if line noise
causes false triggers.
Step 4 — Add tools
A useful agent does things: it looks up an order, books a slot, checks a balance. Declare tools in the agent config. The model calls them mid-conversation. The runtime feeds results back and keeps the caller engaged.http (call an endpoint that you own),
mcp (a remote MCP server over
Streamable HTTP), and telephony tools such as a route to a live human
queue. The full parameter reference, MCP setup, and per-node allow-lists are in
tool calling.
Step 5 — Hand off to a human
The agent thesis for regulated work: the model qualifies, authenticates, and captures compliance context. Then it escalates to a person. This is a warm handoff, not a cold transfer. The caller keeps theirsid and hears
uninterrupted audio. Only the agent leg re-points.
There are two shapes. Pick by target.
Re-attach to another agent
Swap the AI agent for a different one — same call, new brain.
Escalate to a human
Route to a live human queue (browser softphone or SIP deskphone). The
telephony tool
route_to_skill — or an operator transfer — rings the
next available agent and bridges them onto the caller leg.On the wire, escalation pauses the AI leg. It mirrors the caller’s audio to
the human. It injects the human’s mic back to the caller. The caller never
hears a gap. The ACD drives the queue routing and the human-agent ring
(browser or deskphone). The mechanics are in
AI ↔ human handoff.
The product-level bot ⇄ human framing (and warm-handoff context) is in
handoffs.
Step 6 — Record and review
Recording captures both legs: the caller on the left channel, the agent on the right. It lands a stereo WAV in your recording store for playback and review. The engine scores media QoS (loss, jitter, MOS) per call at the same time.Recording is a workspace/trunk-level capability, not a per-call SDK flag
in the current surface. You enable it on the trunk (or workspace). Then the
system captures every call that the trunk carries. There is no
record: true argument on originate() today. To analyze recordings
programmatically, pull them and the QoS metrics from the observability
plane.Record & analyze
Pull both legs and run analysis over the stereo capture.
MOS, jitter & loss
The per-call media-quality score and what drives it.
Call traces
The event-level trace of a single call, keyed on its
sid.Dashboards
Fleet-wide call, quality, and agent reports.
Step 7 — Tear down
End the call cleanly. Hangup releases the media legs. It stops the agent session. It sends the final lifecycle event and the CDR.Put it together
This is the whole outbound-to-teardown flow, minus the config that lives in the agent definition:Next steps
Inbound call recipe
The answer-and-route path, end to end.
Outbound call recipe
Originate, poll, and read the outcome.
Transfer to a human
A runnable warm-handoff recipe.
Bring your own runtime
Use ClutchCall as pure transport with an external agent runtime.

