This page gives copy-paste snippets for calls that arrive from the phone network. Hold onto one idea: an inbound call is the same object as an outbound one. The SIP gateway answers the carrier for you. It publishes the caller’s audio onto the same tracks:
For this reason, every primitive below works on an inbound sid unchanged: attach an agent, open an audio bridge, transfer, or hangup. For the full answer sequence and routing model, read Inbound calls. Each snippet assumes a Voice client:

Route a number to an AI agent

This is the common case. Point a number or trunk at a server-side agent, and you are done. The gateway answers, attaches the runtime, and connects both audio legs. Your process never touches the media. On a native core, set the trunk’s inbound rule to HANDLE_AI. For TypeScript apps, do this in the console at agent.clutchcall.dev instead.
set_inbound_routing is a low-level RPC on the native SDK cores (Python, Go, Rust). The browser/TypeScript SDK does not carry it. Configure inbound routing in the console or in your provisioning pipeline. Then handle the resulting call with the high-level Voice client. See Build a voice agent.

Attach an agent to a live inbound call

You possibly already have the sid from a webhook or your event stream. You can bind an agent to it in the middle of the call, for example after your own IVR gathers intent. The engine connects the bridge for you.
The server handles turn-taking, barge-in, and tool calls. Tune them in Turn detection and Tool calling.

Route to a human or a skill queue

To send callers to people, point the number at a skill queue or an IVR program (VDN) instead of an agent. This is configuration, with no media code. The gateway answers and runs your IVR steps. The ACD then picks the next eligible agent on a browser softphone or a real SIP deskphone.

PBX / ACD

Skills, VDNs, IVR vectors, and the agent picker behind human routing.

AI → human handoff

Answer with AI to qualify the caller, then warm-transfer to a person.

Bridge caller audio into your own code

When you want your own service to drive the call, set the inbound rule to NOTIFY_AND_HANGUP. The flow is:
  1. The gateway tells your app about each incoming call.
  2. You answer the call.
  3. You subscribe uplink to hear the caller.
  4. You publish downlink to talk back. Both go through an audio bridge on that sid.
The attach bridge is written from the server’s point of view. You subscribe uplink and publish downlink. This is the same handle that an outbound call gives you. Configure a webhook_url to receive incoming-call events. See Webhooks.

Pick a codec to skip transcoding

For a PSTN-direct call, ask for G.711. The bridge then passes the caller’s audio through without transcoding. Ask for pcm16 when a realtime model wants raw audio.

Play a greeting back to the caller

Push encoded frames onto downlink as your TTS produces them. See Speak back to the caller.

Transfer an inbound caller

The same sid continues across a transfer. For this reason, any recording or analytics keyed on the sid stay intact. See Transfer to a human.

Hang up and clean up

End the call. Then release the bridge to close both tracks.
Keep the bridge reference alive for the full duration of the call. If the garbage collector removes it, both tracks drop. Always call bridge.close() before call.hangup() so that the tracks close cleanly.

Inbound calls

The full guide: how the gateway answers and where routing decisions live.

Stream to your ASR

Feed caller uplink into your own recognizer.

Place an outbound call

The mirror of this page: originate from code.

Audio bridge API

Full signatures for attach, publishDownlink, and onUplink.