Skip to main content
The Telephony APIs give you a number your app controls. This page puts an Unpod agent on that number instead: the agent answers inbound calls and places outbound ones, and you deploy nothing. In the call chain this is stage 2, Connect: attaching a number to an agent.
No number yet? The Agent SDK Quickstart starts from a free number and covers the same steps.

One number, one mode

A number is answered one way at a time. You pick the mode when you attach it. If you followed the Telephony Quick Start, your number is in the first mode. Moving it to an agent changes three things:
  • Inbound calls go to the agent.
  • The number’s inbound config (its answer URL and callbacks) is cleared. You can set it again.
  • Agent calls use the number as their caller ID.

Before you start

  • A number attached for the Telephony APIs. The Quick Start leaves you with one.
  • UNPOD_BASE_URL, UNPOD_PLATFORM_TOKEN and UNPOD_ORG_HANDLE exported, as in the Introduction.
  • Python 3.12+ and pip install unpod.
  • Room in your plan for the number. The attach checks your plan’s number limit after the detach has already gone through, so an org at or over its limit loses the number to the 402 below.

Create the agent

An agent is a brain plus a voice, under an agent_id you choose. Prompt is a brain that Unpod runs, so there is no process of yours to deploy.
voice_profile takes a name from client.voice_profiles.list(). The Agent SDK Quickstart explains voice profiles and the Playbook brain.

Move the number to the agent

A number in your-app mode can’t be reassigned in place, so detach it, then attach it to the agent.
Detach removes the number’s inbound config: its answer URL and callbacks. A number your org owns stays yours, but a number you took from the shared pool goes back to the pool, where another org can take it. Run both calls together, as below.
The attach prints status=assigned, and the script stops before attaching if the detach did not go through. Check the agent_id spelling before you run it: the attach does not verify that the agent exists, and a number attached to a missing agent goes unanswered. To confirm the routing, read the number’s row from client.telephony.overview(): see Check the Lifecycle.

Call the number

Call the number from any phone. The agent answers with the voice and prompt you gave it. You host nothing: no answer URL, no WebSocket server, no Runner. If nothing answers, check the number’s connection_state: see Number states.

Place a call with the agent

  • You pass no from_number. Caller ID is the number attached to the agent. An agent with several numbers takes turns between them, least recently used first.
  • data is per-call context the brain can read.
  • The call is queued: status starts as pending. See Outbound Calls for status, callbacks and transcripts.

Let your app decide per call

A number on an agent can still have an answer URL. When it does, Unpod asks your answer URL on each inbound call, and the verbs you reply with run instead of the agent. Reply with an empty body or <Response/> and the agent answers. Detach cleared the number’s inbound config, so set the answer URL again: see Point your number at your app. If your server times out or returns an error, the call goes to the agent by default: see When your server is down.

Which attach call

Attach a Number to an Agent has the result fields and every error for the telephony.numbers calls.

Two calls.create

The Telephony APIs are documented for numbers in your-app mode. For calls your app controls, keep a number in that mode, or move this one back.

Move the number back

Release the number from the agent, then attach it for your app:
The same warnings apply: a pool number is free for another org to take between the two calls, and the attach can return the 402 above. Once the attach returns, the number works as from in client.telephony.calls.create.

Next

Run Your Own Brain

Swap Prompt for Runner() and answer turns from your own process.

Brain options

Prompt, Playbook, Runner and Endpoint, and what each one deploys.

Outbound Calls

Campaigns, callbacks and reading results.

Attach a Number to an Agent

The full attach, detach and reassign reference.