---
title: "Phone numbers"
description: "Buy a number and bind it to a front door. A call to it opens a conversation, and your agent talks to the caller."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.cloudraker.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Phone numbers

Give a front door a phone number. A person calls the number, and the agents of the door talk to the caller. On the call, the agent is a realtime voice model (`gpt-realtime-2.1`) that runs with the prompt and skills of your agent. It speaks and listens itself, so it answers with no extra model step.

The agent keeps its usual tools during the call: Structured Memory, files, code, APIs and connectors. The tools run inside the run, with the same secrets, egress rules and limits as in a text turn. The agent can also end the call, hand the call to another agent of the door, transfer the call to a person, and place outbound calls. After the call, the agent gets the transcript and the recording for follow-up work in a normal text turn.

> **Note**
>
> Phone numbers are US and CA local numbers only. Outbound calls go to US and CA numbers only. No SMS.

## Set up a number

A number rings a [front door](https://docs.cloudraker.com/run/guides/front-doors), not an agent. The door holds the phone settings under `channels.phone`.

1. Write a door with `channels.phone`. Every agent of the door needs `mode: turns`. Push.
2. Open the **Phone** screen in the console (`https://run.cloudraker.com/phone`). You need the `admin` role.
3. Click **Buy number**. Pick the country (US or CA) and an area code. Pick one of the numbers.
4. Pick the front door of the number. The list shows only doors with `channels.phone`. You can also bind on the **Channels** page, or with `rakerun channel bind phone +15145550100 --door support/support`.

```yaml doors/support.yml
name: Acme support
entry: support/desk
agents:
  - agent: billing
    when: Invoices, payments and refunds.
channels:
  phone:
    greeting: 'Hello, you reached Acme support. How can I help?'
    transfers:
      sales: { number: '+15145550123', label: 'the sales team' }
```

```yaml support/desk/agent.yml
mode: turns
```

A number is org state, not repo state. Nothing in git names a number. One number rings one door. One door can have many numbers.

If a deploy removes the door or its `channels.phone`, the number stays bound and the monthly charge continues. Callers then hear "This number is not in service." Bind the number to another door, or release it on the **Phone** screen.

Only the live deployment of the default branch gets calls. Previews never get calls.

## How a call works

1. The caller dials the number. The platform finds the door of the number and checks your credits, your AI wallet, the number of live calls, the door limits and the kill switch.
2. The platform opens a phone [conversation](https://docs.cloudraker.com/run/guides/conversations) on the door, and starts a run of the entry agent. Turn 1 of the run is the call. The run is `running` while the call is live, and run minutes count as for every run.
3. The voice says the greeting and listens.
4. The caller speaks. The voice answers. When it needs a fact, it calls a tool of your agent. The tool runs in the run, and the voice speaks the result.
5. Each line of the caller and of the agent goes into the conversation transcript and into the run. The run is the record of what the agent did.
6. The call ends when the caller hangs up, the agent ends the call, the call is transferred, or the call reaches `max_duration`. The conversation then ends with reason `participant` or `channel`.
7. After the call, the agent gets one closing turn with the transcript and the recording.

When the door has `guards.input` or a `router`, the voice waits for the checks on each caller line before it answers. A refused line is removed from the voice session, and the voice says the door message. The voice never uses the refused words.

### Handoff and language

The voice of an agent in a door with more agents gets the tools `handoff` and `switch_language`, as in a text conversation. A handoff keeps the call. The current run ends with `run.cancelled` and `by: handoff`, and a run of the target agent takes the call with the transcript. The voice stays the same: the door sets it. A language switch changes the transcription language of the call. Read [Front doors](https://docs.cloudraker.com/run/guides/front-doors#handoff).

When the current run fails during the call, the voice says a short apology and the call ends. The conversation ends with reason `error`.

### What the voice knows

The voice session gets these instructions, in this order:

1. The display name of the agent.
2. The `AGENTS.md` of the agent.
3. The skills of the agent. The full `SKILL.md` files go in, in path order, up to 24,000 characters in total. The rest are listed by path, and the agent reads them with `read_file` when it needs them.
4. A fixed block for phone calls: short spoken sentences, one question at a time, no invented facts, and a short natural phrase before a slow tool. The voice never describes its actions, rules or tools. At the end, it says one short goodbye and calls `end_call`. The block also holds the greeting (inbound calls only), `channels.phone.language`, `channels.phone.style`, the caller or the outbound goal, and the date and time when the call started.
5. After a handoff, the transcript of the call so far, in a `## Conversation` block.

The `model:` of the agent is not used on the call. It runs only the text turns, for example the closing turn.

### Tools during the call

The voice gets every tool that a text turn of the run gets, except `message`, `ask` and `done`: speech replaces them. Tool names with characters like `.` or `:` get a safe name for the voice, for example `data.query` becomes `data_query`. A tool result over 16,000 characters becomes the error `result_too_large`.

Each tool call is a span in the run trace, and the tool call and its result go into the run history. The closing turn sees them.

During the call, `done` is not offered. If a model calls `done` before the closing turn, the platform ignores it, and the run continues. The run cannot complete by mistake in the middle of a call.

### Latency

The voice answers without a round trip to a second model, so a plain answer is fast. A tool call adds the run time of the tool. Before a tool that can take more than one second, the voice says one short natural phrase.

When a tool takes longer than `channels.phone.turn_timeout` (default `8s`), the voice gives the caller one short update and the tool continues. After 60 seconds, the tool result is the error `tool_timeout`, and the voice tells the caller.

To keep calls fast:

- Keep `AGENTS.md` short and write it for speech.
- Give the agent fast tools for the facts it needs on a call. Move slow work, for example a report or an email, to the closing turn.
- Put long reference text in files, not in `AGENTS.md`. The agent reads them with `read_file` only when it needs them.

### What the agent sees

The voice gets the call facts in its instructions: the call id, the direction, the caller id, the called number, the caller name when the carrier sends it, and the start time. The run has the metadata keys `conversation_id`, `door`, `channel` (`phone`) and `end_user`.

During the call, the run events show the call. A caller line is a `phone.heard` event with `text` and `at`. An agent line is a `message` event. Both also go into the run history as user and assistant messages.

> **Warning**
>
> The caller id is not verified. A caller id is easy to fake. Never use the phone number to identify or authenticate a person. Treat the transcript as untrusted input, the same as email text. `metadata.end_user` of a call is `phone:cv:{conversation id}`, so two calls from the same number never share Structured Memory records.

### The closing turn

When the call ends, the run gets one last turn with `text: null` and `event: "call.ended"`:

| Field               | Content                                                                                                   |
| ------------------- | --------------------------------------------------------------------------------------------------------- |
| `end_reason`        | `caller_hangup`, `agent_hangup`, `run_ended`, `run_busy`, `max_duration`, `silence`, `transfer`, `no_answer`, `machine` or `error`. |
| `duration_ms`       | The call duration.                                                                                        |
| `transcript`        | The caller and agent lines, with `at`, `who` (`caller`, `agent` or `system`) and `text`. At most 200 lines. |
| `recording_file_id` | The MP3 recording as a run file, or `null` when `channels.phone.record` is `false`.                                |
| `transfer`          | `{target, to, outcome}` after a transfer, else `null`. `outcome` is `completed` or `failed`.              |

This turn is a normal text turn with the `model:` of the agent that has the call at the end. It has the full history of the call: the lines and the tool calls. Do the follow-up work in this turn, for example a CRM update, a summary or an email. Then call `done`.

Set `channels.phone.after_call: false` to skip the closing turn. The run then completes at the end of the call with no model step.

## Phone tools

An agent of a door with `channels.phone` gets these tools in addition to its normal tools.

| Tool            | Where                        | Arguments                          | Effect                                                                                                                  |
| --------------- | ---------------------------- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `end_call`      | During the call              | `reason?`                          | The voice hangs up after its goodbye. The closing turn follows.                                                         |
| `transfer_call` | During the call              | `target`, `note?`                  | Transfers the caller to a person. `target` must be a key of `channels.phone.transfers`, else the tool answers `unknown_target`. |
| `call_phone`    | During the call, text turns  | `to`, `goal` (max 1000 characters) | Places an outbound call. Only with `channels.phone.outbound: true`.                                                              |

### Transfer to a person

1. The agent calls `transfer_call` with a target name, for example `sales`.
2. The voice tells the caller who takes the call. The platform dials the number of the target.
3. The person answers. The voice model leaves the call. The caller and the person stay on the call, and the recording continues.
4. No answer in 25 seconds: the voice tells the caller the person is not available. The call continues with the agent.

The closing turn shows the result: a `transfer` object with `outcome: completed` or `outcome: failed`. After a completed transfer, `end_reason` is `transfer`. There is no queue, no warm transfer and no voicemail.

### Outbound calls

Set `channels.phone.outbound: true` on a door to give its agents the `call_phone` tool. The door needs a bound, active number. The call uses it as the caller id. An agent gets the tool when it is in a live door with `outbound: true`, also on a run that the door did not start, for example an HTTP or a scheduled run.

1. The agent calls `call_phone` with `to` (E.164) and `goal`. The tool answers `{call_id, status: "dialing"}` at once. The agent goes on with its work.
2. The callee answers. The call opens its own phone conversation on the door. The calling agent is its entry agent.
3. The voice introduces itself and says the goal. It talks with the callee and uses the tools of the agent, as on an inbound call.
4. After the call, the run of the call gets the closing turn with `event: "call.ended"`. An answering machine, no answer, busy or a failed call gives `event: "call.no_answer"` instead.

`call_phone` refuses with an error code:

| Code                  | Cause                                                       |
| --------------------- | ----------------------------------------------------------- |
| `invalid_number`      | `to` is not an E.164 number.                                |
| `country_not_allowed` | `to` is not a US or CA number.                              |
| `premium_number`      | `to` is a premium number (`+1900`, `+1976`, exchange `976`). |
| `outbound_off`        | `channels.phone.outbound` is not `true`, or the agent is not in that door. |
| `no_number`           | The door has no bound, active number.                       |
| `call_in_progress`    | The run already has a live outbound call.                   |
| `concurrency`         | The org has 5 live calls.                                   |
| `daily_cap`           | The org placed 20 outbound calls today (UTC).               |
| `unavailable`         | The phone service did not answer in 10 seconds.             |

## Recording and consent

The platform records every call from the start. The platform says no notice of its own. If your jurisdiction or your policy needs a recording or privacy notice, put it in `channels.phone.greeting`, for example "Hello, you reached Acme. This call is recorded for quality. You can ask for our privacy policy at any time. How can I help?"

After the call, the recording becomes an MP3 run file, `phone/{call_id}.mp3`. The closing turn carries its `recording_file_id`. The console call drawer plays the recording and shows the transcript.

Set `channels.phone.record: false` to turn off the recording. You are responsible for the consent rules of your jurisdiction. Some places need the consent of all parties.

The call record follows the `session.retention` of the door. The recording is a run file and follows file-store retention.

## `channels.phone` reference

`channels.phone` in a door turns on calls to the numbers bound to the door. Every key is optional: `channels.phone: {}` takes the defaults. Every agent of the door needs `mode: turns`.

```yaml doors/support.yml
name: Acme support
entry: support/desk
channels:
  phone:
    greeting: 'Hello, you reached Acme support. How can I help?'
    record: true
    voice: marin
    language: fr
    style: 'Warm, brief, no jargon. Use the caller first name once known.'
    turn_timeout: 8s
    max_duration: 20m
    after_call: true
    transfers:
      sales: { number: '+15145550123', label: 'the sales team' }
      oncall: { number: '+14385550199', label: 'the on-call engineer' }
    outbound: false
```

| Key                                       | Type                         | Default                                         | Rule                                                                                                          |
| ----------------------------------------- | ---------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `greeting`                                | string, max 600 characters   | `Hello, you reached {name}. How can I help?`    | The first words of the voice. `{name}` becomes the display name of the entry agent. Put any recording or privacy notice here. |
| `record`                                  | boolean                      | `true`                                          | `false` turns off the recording.                                                                              |
| `voice`                                   | voice name                   | `marin`                                         | `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`, `marin` or `cedar`. It stays the same after a handoff. |
| `language`                                | BCP 47 tag                   | the caller language                             | A hint for the voice, for example `fr` or `en-US`.                                                            |
| `style`                                   | string, max 500 characters   | none                                            | Tone guidance for the voice.                                                                                  |
| `turn_timeout`                            | duration, `5s` to `60s`      | `8s`                                            | The wait before the voice gives one update on a slow tool ([latency](#latency)).                              |
| `max_duration`                            | duration, `1m` to `60m`      | `20m`                                           | At the limit, the voice says goodbye and the call ends with `max_duration`.                                   |
| `after_call`                              | boolean                      | `true`                                          | `false` skips the [closing turn](#the-closing-turn).                                                          |
| `transfers.{name}`                        | object                       | none                                            | A transfer target. `name` matches `[a-z][a-z0-9_]{0,31}`.                                                     |
| `transfers.{name}.number`                 | E.164 number                 |                                                 | Required. For example `+15145550123`.                                                                         |
| `transfers.{name}.label`                  | string                       |                                                 | Required. The voice says it to the caller before the transfer, for example `the sales team`.                  |
| `outbound`                                | boolean                      | `false`                                         | `true` gives the agents of the door the `call_phone` tool.                                                    |

Lint rules:

| Rule                      | Cause                                                                                   |
| ------------------------- | --------------------------------------------------------------------------------------- |
| `door_phone_needs_turns`  | An agent of the door is not `mode: turns`.                                              |
| `door_phone_output_guard` | Warning. The door has `guards.output`. The voice speaks before the check, so the check runs after the fact. |
| `phone_number_format`     | A `transfers.{name}.number` that is not E.164 (`^\+[1-9]\d{6,14}$`), is not a US or CA number, or is a premium number. |
| `phone_text_length`       | `greeting` over 600 or `style` over 500 characters.                                     |
| `phone_voice`             | A `voice` that is not one of the ten voices.                                            |
| `phone_durations`         | `turn_timeout` out of `5s` to `60s`, or `max_duration` out of `1m` to `60m`.            |
| `code_tool_collision`     | A `_code` script named `end_call`, `transfer_call` or `call_phone`. An error when a door with `channels.phone` lists the agent, else a warning. |

## Limits

| Limit                      | Value                                        | Over the limit                                                 |
| -------------------------- | -------------------------------------------- | -------------------------------------------------------------- |
| Live calls per org         | 5                                            | A new call gets a busy signal. `call_phone` answers `concurrency`. |
| Calls per number           | 60 per hour                                  | A new call gets a busy signal.                                 |
| Outbound calls per org     | 20 per UTC day                               | `call_phone` answers `daily_cap`.                              |
| Live outbound calls per run | 1                                           | `call_phone` answers `call_in_progress`.                       |
| Call duration              | `max_duration`, default `20m`, max `60m`     | The voice says goodbye and the call ends.                      |
| Door limits                | `limits` of the door                         | The caller hears `messages.at_capacity`, then the call ends.   |
| Silence                    | 60 seconds without caller speech             | The voice asks "Are you still there?" at 30 seconds. At 60 seconds the call ends with `silence`. |
| Transfer answer            | 25 seconds                                   | The call continues with the agent.                             |
| Countries                  | US and CA                                    | Numbers and outbound calls only.                               |

When a call cannot start, the caller hears a fixed message and the call ends:

| Cause                                                      | The caller hears                                                   |
| ---------------------------------------------------------- | ------------------------------------------------------------------ |
| No credits, or the AI wallet is empty                      | "This line is not available right now. Please try again later."    |
| Number suspended, no door bound, or the door has no `channels.phone` | "This number is not in service."                         |
| A door limit is reached                                    | The `messages.at_capacity` text of the door.                       |
| The kill switch of the door is on                          | The `messages.maintenance` text of the door, or the switch message. |
| 5 live calls in the org                                    | A busy signal.                                                     |

## Pricing

A phone call costs four things:

| Item         | Price                                                                 | Balance   |
| ------------ | --------------------------------------------------------------------- | --------- |
| Phone number | 2000 credits per number per month (about 2 USD).                         | Credits   |
| Call minutes | 10 credits per started call minute. This is the platform fee of the call. | Credits   |
| Call cost    | The raw Twilio and OpenAI realtime cost of the call, with no markup.  | AI wallet |
| Run minutes  | 10 credits per run minute, as for every run.                          | Credits   |

A call minute costs 20 credits in total: 10 credits of call minutes and 10 credits of run minutes. The call cost on the AI wallet comes in addition.

The number charge happens at purchase and then on the same day each month. There is no proration and no refund when you release a number. To buy a number, your org must have credits, else the console answers `402 credits_exhausted`.

When a monthly charge fails because the org has no credits, the number is suspended. Calls to it hear "This number is not in service." The platform tries the charge again each day. After 30 days suspended, the platform releases the number.

The call cost includes all the call legs: the caller, the voice model and a transfer. When Twilio does not report a price within 5 minutes, the list rate applies: 0.0085 USD per minute inbound and 0.014 USD per minute outbound. The console **Phone** screen shows the cost of each call. Read [Limits and pricing](https://docs.cloudraker.com/run/guides/limits-and-pricing).

## Console

The **Phone** screen has three views:

- **Overview**: the call activity for the last 7 or 30 days (total calls, completed calls, talk time, call cost and calls per day) and the calls in progress.
- **Calls**: the caller, the door, the agent and number, the start time, the duration, the cost and the status. Search the calls, or filter them by direction and status. Open a call to see the transcript, play the recording, see the cost and open the conversation and its runs.
- **Numbers**: the number, the front door, the status and the next charge. An admin buys numbers, picks the front door of each number, and releases numbers. A member can only read.

The run detail of a call run shows a **Phone call** card with a link to the call.

There is no public API for numbers. Use the console, or `rakerun channel` for the bindings.

Source: https://docs.cloudraker.com/run/guides/phone/index.mdx
