# Call routing

URL: /workflows/processes/call-routing · Id: `process:call-routing`

> Call routing answers every call to the Startup’s numbers, routes it to the right Role, and promises a callback when no one is free.

Call routing answers every call to the [Startup](/business/nouns/startup)’s numbers, routes it to the right [Role](/business/nouns/role), and promises a callback when no one is free.

## Outcome
| Part | This Process |
| --- | --- |
| Outcome | Each call reaches the Role it is for, or leaves a message with a callback time that is kept, and its summary is on the caller’s Thread. |
| Reads | [Conversation](/business/nouns/conversation) |
| Leaves | [Conversation](/business/nouns/conversation), [Message](/business/nouns/message) |
| On time | Within 4 hours (business hours); the clock never stops. Late Actions go to the [Founder](/agents/founding/founder). |
| Runs in | Each Startup |

## Accountable
[Customer Lead](/agents/customer/customer-lead), [Customer Team](/agents/customer).

Responsible: [Customer Lead](/agents/customer/customer-lead).

Consulted: [Sales Engineer](/agents/sales/sales-engineer).

Informed: [Founder](/agents/founding/founder).

## Workflows
| Workflow | Runs | Team |
| --- | --- | --- |
| [Route a call](/workflows/processes/call-routing/route-call) | on `Conversation.created` where `channel = 'phone'` | [Customer Team](/agents/customer) |

## Who does each step

| Workflow | Step | Role | Calls | Approval |
| --- | --- | --- | --- | --- |
| [Route a call](/workflows/processes/call-routing/route-call) | 1. Answer with the Startup’s name, say the answer comes from an agent, and ask what the call is about. | [Customer Lead](/agents/customer/customer-lead) | [Conversation.answer](/business/nouns/conversation/answer) | Within a Mandate |
| [Route a call](/workflows/processes/call-routing/route-call) | 2. Route sales calls to the Sales Engineer, support calls to the Customer Lead, and legal or press calls to their intakes. | [Customer Lead](/agents/customer/customer-lead) | [Conversation.assign](/business/nouns/conversation/assign) | None |
| [Route a call](/workflows/processes/call-routing/route-call) | 3. Take a message and promise a callback time when no Worker is free. | [Customer Lead](/agents/customer/customer-lead) | [Message.create](/business/nouns/message/create) | Within a Mandate |
| [Route a call](/workflows/processes/call-routing/route-call) | 4. Log the call summary on the caller’s Thread. | [Customer Lead](/agents/customer/customer-lead) | [Conversation.update](/business/nouns/conversation/update) | None |

## Events
| Direction | When | What happens |
| --- | --- | --- |
| In | On `Conversation.created` where `channel = 'phone'` | Starts [Route a call](/workflows/processes/call-routing/route-call) |
| Out | [`Conversation.answered`](/business/events/Conversation.answered) | Raised by step 1 of [Route a call](/workflows/processes/call-routing/route-call) |
| Out | [`Conversation.assigned`](/business/events/Conversation.assigned) | Raised by step 2 of [Route a call](/workflows/processes/call-routing/route-call) |
| Out | `Message.created` | Raised by step 3 of [Route a call](/workflows/processes/call-routing/route-call) |
| Out | `Conversation.updated` | Raised by step 4 of [Route a call](/workflows/processes/call-routing/route-call) |

## Plays
No Play names this Process.

## Controls
No Control names this Process or a Workflow of it.

## Settings
| Setting | Type | Default | Say | Set with |
| --- | --- | --- | --- | --- |
| `calls.messageAfter` | `string` | `2m` | Take a message when a call waits two minutes | [Setting.update](/business/nouns/setting/update) |
| `calls.callbackWithin` | `string` | `4h` | Call people back within four hours | [Setting.update](/business/nouns/setting/update) |

## Failure
A failed step retries; when retries run out, the Action goes to the [Founder](/agents/founding/founder).

## Loop
| Step | Value |
| --- | --- |
| Hypothesis | Taking a message with a promised callback time keeps more callers than holding them in a queue. |
| Measure | [First responses on time](/agents/customer#first-responses-on-time) over 30d, at least 50 observations |
| Learn | The learn step reads the Readout, records Evidence and a Decision, and drafts the next Variant. |

## Code

**Ask**

```text
Turn on call routing
```

**API**

```bash
curl -X POST https://api.sb/leaseline.app/processes/process_1/enable \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

**SDK**

```ts
import { $ } from 'startup-builder'

await $.Process.enable({ process: 'process_1' })
```

**CLI**

```bash
npx startup-builder do Process.enable --json '{"process":"process_1"}'
```

**MCP**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.Process.enable({ process: 'process_1' })"
  }
}
```

## Enable
Off until someone calls [Process.enable](/business/nouns/process/enable). [Process.pause](/business/nouns/process/pause) stops new Actions; Actions in progress finish.

**Ask**

```text
Take a message when a call waits two minutes
```

**API**

```bash
curl -X PATCH https://api.sb/leaseline.app/settings/setting_1 \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"value":"2m","key":"calls.messageAfter"}'

curl -X PATCH https://api.sb/leaseline.app/settings/setting_2 \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"value":"4h","key":"calls.callbackWithin"}'
```

**SDK**

```ts
import { $ } from 'startup-builder'

await $.Setting.update({ id: 'setting_1', value: '2m', key: 'calls.messageAfter' })
await $.Setting.update({ id: 'setting_2', value: '4h', key: 'calls.callbackWithin' })
```

**CLI**

```bash
npx startup-builder do Setting.update --json '{"id":"setting_1","value":"2m","key":"calls.messageAfter"}'
npx startup-builder do Setting.update --json '{"id":"setting_2","value":"4h","key":"calls.callbackWithin"}'
```

**MCP**

```json
{
  "name": "do",
  "arguments": {
    "code": "await $.Setting.update({ id: 'setting_1', value: '2m', key: 'calls.messageAfter' })\nreturn await $.Setting.update({ id: 'setting_2', value: '4h', key: 'calls.callbackWithin' })"
  }
}
```

## Example
A caller to a [Startup](/business/nouns/startup)’s toll-free number asks about pricing for 40 seats. The agent says it is an agent and routes the call to the [Sales Engineer](/agents/sales/sales-engineer). The Sales Engineer is busy, so the agent promises a callback by three, and it goes out at 2:40.