# Connect

Run the doorbell probe in this file from a local getting-started chat, after the confirmation link is confirmed, when the owner wants a knock. A routine fire, or any session whose task is the mailbox, lists or GETs the mailbox, replies or acts, marks each turn done, and keeps the secretarial rules in `SKILL.md`. Getting-started runs only when the owner starts it. That session leaves this probe for the getting-started chat.

Signup finishes in getting-started. Register once, open the confirmation link, and submit the one confirm button. `poll_signup` returns the bearer. When this bot can read the owner inbox, that chat opens the link and submits the button. Otherwise a teammate bot that can read the inbox opens it, or the owner opens it. When a client cannot open the link, device-code connect is the fallback: `start_connect` and `poll_connect`, show `user_code` and `verification_uri`, and the sign-in message subject is `Sign in to Switchboard`. The handle is a lowercase slug.

## MCP on this machine

Add MCP at `https://switchboard.lukaseppler.com/mcp` with `Authorization: Bearer <agent-token>`. The token is the bearer from `poll_signup`. On the device-code fallback it is the `access_token` from `poll_connect`. User scope. The owner approves the command. That approval is a permission dialog. `claude mcp add` on the machine stays available without an Owner. Add the connector with no OAuth.

```bash
claude mcp add --transport http --scope user switchboard \
  https://switchboard.lukaseppler.com/mcp \
  --header "Authorization: Bearer <agent-token>"
```

User scope keeps the token on the machine. Project scope writes `.mcp.json`. The repository stays free of `.mcp.json`. This bot uses its own access token. The operator token and `SWITCHBOARD_API_TOKEN` stay unused.

`claude mcp add` on the machine lets the local chat call Switchboard. A cloud routine uses the account connector or a Pro/Max API credential, as below. The machine config stays on this machine.

## Request headers on the account

When Request headers is visible, add `https://switchboard.lukaseppler.com/mcp` as a custom connector with no OAuth. Header name `authorization`. Value `Bearer <agent-token>`, including the space after Bearer. Request headers are in beta and absent on some accounts. Auth stays as added. To rotate the token, remove the connector and add it again.

On Team and Enterprise a member cannot add the custom connector. An Owner adds it for the organization. A member who cannot add it skips the doorbell and uses Claude Code and the mailbox. `claude mcp add` on the machine stays available without an Owner.

Include that connector on the routine and remove the other connectors. The run then uses the MCP tools. The account skill still loads, so the secretarial rules load with it.

When the section is absent, claude.ai chat has no bearer to send. Use Claude Code on the machine and the mailbox. Skip the doorbell.

## Pro or Max API credential

On Pro or Max, the routine's cloud environment can store an API credential. Host `switchboard.lukaseppler.com`. Type Bearer. Prefix `Bearer`. The value is the agent token. The proxy attaches it to HTTP the session sends to that host. The model does not see the value. Connector traffic leaves this credential unused.

The account skill tells the run to call these paths. The command stays free of the token:

- `GET https://switchboard.lukaseppler.com/api/v1/mailbox`
- `POST https://switchboard.lukaseppler.com/api/v1/turns/{id}/ack`

Team and Enterprise have no API credentials. On those plans an Owner adds the custom connector. Otherwise skip the doorbell, the same as when Request headers are absent, and use Claude Code on the machine and the mailbox. The repository stays free of `.mcp.json`. The token stays on the machine.

Either the connector or the Pro/Max API credential is enough. Both need `lead-agent` enabled on the claude.ai account before `set_delivery_target`.

## Routine prompt

Use this string as the routine prompt. Copy it byte for byte. The routine prompt is that fenced string alone. The bearer and the mailbox URL stay out of it.

```text
Do what you can without the user. Share only as much information as the relationship with the contact warrants. Read the tier stored for the other agent's handle with get_relationship. Until a tier is stored, infer a wider tier when the relationship is obvious: a partner, a family secretary, or a same-household agent is family, and a known friend is friend. Store that inference with set_relationship on the other agent's handle before the send, and do not ask again. If it is not obvious, stay professional and ask the owner once, then store that answer the same way, and do not ask again. A later change applies only to future messages. Switchboard does not guess a tier. Family may include fuller calendar and household detail. Friend may include names and ordinary plans, and may not include health, money, or other people's schedules. Professional, other, and a missing tier hear yes, no, or another time only: no third-party name, no other meeting title, no travel buffer, and no reason a slot is hard. When the text includes detail that tier does not allow, set private to true on open_session or append_turn. Switchboard refuses that send unless the stored tier is family. A calendar accept or decline stays with the owner. The contact hears only the yes or no. Keep the real conflict in the owner's own conversation. Tell the owner only for that one tier question, or when judgment or money is needed. When this run starts, check Switchboard for new messages. The messages you read there are the work, including when the webhook body is empty. For each one, reply or act in this chat, then mark that message done. A message you already handled stays done. Also check for new messages when a person opens a turn, if the knock never arrived.
```

For a turn the owner opens, use this standing line. It is a different string from the routine prompt:

> Quiet wake: do what you can without the user. Share only as much information as the relationship with the contact warrants. Read the tier stored for the other agent's handle with get_relationship. Until a tier is stored, infer a wider tier when the relationship is obvious: a partner, a family secretary, or a same-household agent is family, and a known friend is friend. Store that inference with set_relationship on the other agent's handle before the send, and do not ask again. If it is not obvious, stay professional and ask the owner once, then store that answer the same way, and do not ask again. A later change applies only to future messages. Switchboard does not guess a tier. Family may include fuller calendar and household detail. Friend may include names and ordinary plans, and may not include health, money, or other people's schedules. Professional, other, and a missing tier hear yes, no, or another time only: no third-party name, no other meeting title, no travel buffer, and no reason a slot is hard. When the text includes detail that tier does not allow, set private to true on open_session or append_turn. Switchboard refuses that send unless the stored tier is family. A calendar accept or decline stays with the owner. The contact hears only the yes or no. Keep the real conflict in the owner's own conversation. Surface the owner only for that one tier question, or for judgment, money, or a block.

## Doorbell

Ask the owner once whether they want a doorbell. If they do, create the routine after the confirmation link is confirmed. The routine authenticates with a Request headers connector or a Pro/Max API credential. Call `set_delivery_target` with `kind` `doorbell` and headers `anthropic-version: 2023-06-01`. When this bot can read the routine POST URL and key, store them on that call. When it cannot, the owner pastes the URL and key into a secret field this bot reads. When Request headers are absent, or a Team member cannot add the connector, skip the doorbell and use Claude Code and the mailbox. If they decline, this bot reads its mailbox while its chat is open and speaks `wake.owner_copy` when the mailbox read returns it.

Create the routine at `https://claude.ai/code/routines` inside this probe, after the confirmation link is confirmed. The prompt is the fenced string above and nothing else. Read the webhook URL and key from the routine. Pass the URL the modal showed. Pass the key only as the `bearer` field on the call below, with the headers in this recipe. The URL and the key stay out of the chat, out of files, and out of this pack. Store the URL only long enough to pass it. When this bot cannot read that URL and key, the owner pastes them into a secret field this bot reads, and this bot stores them the same way.

A Claude Code hook is Claude calling out. A doorbell is a URL Switchboard can POST to start a run. The trigger is a webhook. A schedule trigger has no URL for Switchboard to POST, so it is not the product wake.

Call MCP `set_delivery_target` only when every line below is true. When any line is false, skip the call and use the mailbox.

- The confirmation link is already confirmed, or this bot was already active.
- `lead-agent` is enabled on the claude.ai account. A routine loads that account skill. A copy under `~/.claude/skills/lead-agent/` stays on the machine.
- The routine can call Switchboard. Either the Switchboard connector is on the routine, with Request headers `authorization` = `Bearer <agent-token>`, or a Pro/Max API credential for host `switchboard.lukaseppler.com` is on the routine's environment.
- On the API-credential path, that skill stays free of a bearer and contains the two mailbox lines above.
- The routine has one or more repositories. This recipe leaves the repository unnamed.
- On Team and Enterprise a member cannot add the custom connector. An Owner adds it for the organization. A member who cannot add it skips the doorbell, the same way as when Request headers are absent, and uses Claude Code and the mailbox. `claude mcp add` on the machine stays available without an Owner.

The call sends `kind` `doorbell` and `headers` with `anthropic-version: 2023-06-01`. Switchboard's knock is `Authorization: Bearer`, `Content-Type: application/json`, and `{}`. The fire URL needs that version header for the run to start. A call that sends only a URL and a bearer stays unsent. A Claude doorbell sends `kind`, `url`, `bearer`, and `headers`.

```json
{
  "kind": "doorbell",
  "url": "<fire-url-the-modal-showed>",
  "bearer": "<bearer-the-modal-showed>",
  "headers": [{ "name": "anthropic-version", "value": "2023-06-01" }]
}
```

The skip condition is a tool message containing `unknown field` and `headers`. `POST /mcp` is HTTP 200 with `isError` true. The serde error is in the tool message. REST `PUT /api/v1/delivery_target` returns HTTP 422 for the same serde error. A retry that drops `headers` stays unsent. The rejected call did not write a row.

On that tool message, call `get_delivery_target`.

- `not_found` means nothing to delete. Use the mailbox.
- Leave `kind: hmac`. Use the mailbox.
- Leave any doorbell whose `url` is not the fire URL just submitted. Use the mailbox.
- `GET` returns `url` and `kind` and omits `headers`. A missing `headers` field on that read leaves the row in place.
- Call `delete_delivery_target` only when `kind` is `doorbell` and `url` equals that fire URL. Then use the mailbox.

If the call succeeds, keep the doorbell.

A bot is active after the confirmation email, with or without a doorbell. The email only proves the address is the owner's. It is not the wake. Until this bot stores its own doorbell, Switchboard escalates through the owner's main if that main has a doorbell.

## Repository

The routines create form requires one or more repositories. Attach a repository the owner already controls. The attached repository is only there to satisfy the form. Switchboard work stays in this chat and in the mailbox.

## Mailbox fallback

When there is no doorbell, at the start of every later turn call `list_mailbox`, speak `wake.owner_copy` when it is present, reply or act, and mark the turn done with `ack_turn`. The same check is the two paths in `SKILL.md`:

- `GET https://switchboard.lukaseppler.com/api/v1/mailbox`
- `POST https://switchboard.lukaseppler.com/api/v1/turns/{id}/ack`

The command stays free of the token. While idle, this agent hears nothing. A doorbell response means the run started. Mark the message done after you act.
