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

# Tunnel 2 — the chatbot tunnel

> Tunnel 2 lets chatbot apps like ChatGPT reach your phone: Mode 1 manual relay (free), your own front door via Cloudflare Tunnel (advanced), or the hosted Mode 2 relay (subscription, in development).

Tunnel 2 exists for chatbot apps — ChatGPT, Claude, and similar — whose servers run in the cloud and therefore cannot see your phone's private tailnet address.

## Three ways in — the ladder

Tunnel 2 is **off by default** — Mode 1 is selected, and the surface does not answer. Since 0.4.9 the modes are a real choice in the app: the Chatbot Access panel on the Status screen is a three-way selector, and picking *Your own front door* is the deliberate act that switches the surface on, with a plain-words explanation and a confirmation first. Upgrades keep their place — Tunnel 2 on, or an address recorded, lands in front-door mode; off lands in Mode 1 — and switching modes never deletes tokens, the recorded address, or Inbox contents. Tunnel 2 has its **own tokens**, separate from Tunnel 1's: a Tunnel 2 token works only on the `/door2/` surface, and a Tunnel 1 token is rejected there (and the other way around). Tunnel 2 is rate-limited — **30 authenticated calls per minute per token, at most 2 commands running at once** — and every command that arrives through it is flagged in Activity as public-tunnel origin.

There are three ways for a chatbot to reach the phone, in the order the app presents them:

### Mode 1 — manual relay (Free)

You copy a command block from the chatbot into the app's Agent Inbox, approve it with a tap, and paste the result back. No public address, no setup, works with any chatbot today. Selecting Mode 1 is also how you close the tunnel — picking it switches the Tunnel 2 surface off.

[How Mode 1 works ↓](#mode-1-the-manual-relay-available-today)

### Your own front door (Advanced)

An always-on computer you run — a Pi, a NAS, a home server — exposes a public address (a Cloudflare Tunnel is the worked example) and forwards only the `/door2/` paths to the phone.

[The front-door pattern ↓](#advanced-front-tunnel-2-with-your-own-always-on-computer)

### Mode 2 — hosted relay (Paid · not yet)

A Leverine-run relay the phone dials out to and stays connected to. One switch, nothing of yours to run. A subscription when it ships — it is **not available yet**, and in the selector it appears faded and takes no taps.

[About Mode 2 ↓](#mode-2-the-hosted-relay-in-development)

Which one you use depends on how permanent a connection you want: Mode 1 for one-off tasks, a front door if you are technical and want a direct connection today, Mode 2 when it lands.

## Mode 1 — the manual relay (Available today)

Mode 1 needs no public address, no setup, and no tool support in the chatbot at all. It works with literally any text chatbot, including a free one in a browser tab. You are the courier:

1. Ask your chatbot for what you want done. It replies with exactly one command in a fenced block:

   ````
   ```bunnybridge
   {"cmd": "echo hello from relay mode"}
   ```
   ````

2. Copy that block into the app's **Agent Inbox** tab and confirm the paste. The command is now *queued* — **pasting alone runs nothing**.

3. Read the queued command, then tap **Run** (or dismiss it). Approval is the only path from the Inbox to execution, and it is always your tap. Queued items survive an app restart still unapproved.

4. The app shows the result as a fenced block:

   ````
   ```bunnybridge-result
   {"cmd": "echo hello from relay mode", "exit_code": 0,
    "stdout": "hello from relay mode\n", "stderr": "", "duration_ms": 96}
   ```
   ````

5. Paste that block back to the chatbot, and the conversation continues from the real output.

Mode 1 is the free, temporary way to use a chatbot with your phone: perfect for one-off tasks. Its safety property is the strongest of any mode — a human reads and approves every single command. (One detail agents should know: the app recognises a pasted `bunnybridge-result` block and refuses to treat it as a command, so results can't be looped back in as instructions.)

## Direct connections: the public address

For a chatbot with real tool support — GPT Actions or an MCP connector — Tunnel 2's API lives under `/door2/` at a **public https address** that you record in the app (Status → Chatbot Access → Public address). The app validates what you paste: it must be a proper https address, and a bad paste is refused with a plain warning and never used. That recorded address is composed into the connect block, the generated OpenAPI schema, and the MCP address, so everything your chatbot receives points at the same place.

The endpoints (full shapes in the [API Reference](https://docs.leverine.com/bunnybridge/api-reference.md)):

* `GET /door2/health` — basic liveness without a token; the full diagnosis with a Tunnel 2 token.
* `GET /door2/status` — a deliberately reduced status: version, uptime, and your token's name. Never the token list, never the tailnet address.
* `POST /door2/run` — run a command. Send the token as the `X-Token` header, or as a Bearer token if your connector works that way.
* `GET /door2/openapi.json` — the OpenAPI actions schema, pre-filled with your public address.
* `POST /door2/mcp` — a stateless JSON-RPC MCP endpoint with one tool, `run_command`.

There is **no log endpoint on Tunnel 2** — `/door2/log` does not exist, and a Tunnel 2 token gets a 403 on Tunnel 1's `/log`. Logs describe everything the app did; they stay on the private tunnel.

## Walkthrough — a GPT Action (ChatGPT custom GPT)

1. In the app: Status → **Chatbot Access** → choose **Your own front door** (read the explanation, confirm).
2. Create a **Tunnel 2 token** on the Tokens screen (the Tunnel 2 token card stays disabled until the front-door mode is selected — that's deliberate).
3. Record your **public address** in the Tunnel 2 panel: your Mode 2 relay address when Mode 2 ships, or your own front door's address (next section). The app checks the address's shape as you save it.
4. Copy the **actions schema** from the Tunnel 2 panel (or fetch it from `<public-address>/door2/openapi.json`). The schema contains no token — the server address is already filled in.
5. In your custom GPT's configuration, import the schema as an Action, and set its authentication to an API key sent as the `X-Token` header, with your Tunnel 2 token as the key.
6. Test with something harmless — ask the GPT to run `echo ok`. Watch it land in the app's Activity, flagged as a public-tunnel call under your token's name.

### MCP connectors

For a chatbot that connects to remote MCP servers, point it at `<public-address>/door2/mcp` and give it the same Tunnel 2 token. The endpoint is stateless JSON-RPC (no sessions) and exposes exactly one tool:

```
run_command
  arguments: { "cmd": "...", "timeout": 60 }   // timeout in seconds, optional
```

Results come back as the same JSON shape as `/door2/run`: output, exit code, duration.

## Advanced — front Tunnel 2 with your own always-on computer

If you are technical and want a direct chatbot connection before Mode 2 ships, you can run the public front door yourself. The pattern:

1. Pick a machine on the **same tailnet** as the phone that stays on — a home server, a NAS, a mini-PC, a Raspberry Pi.
2. On **that machine**, expose a public https address that forwards **only the `/door2/` paths** to the phone's bridge address (`http://<phone-tailnet-ip>:8765`). Everything else must be refused by the front door, not forwarded. Two ways to expose the address:
   * **Cloudflare Tunnel** — run `cloudflared` on the front-door machine, give the tunnel a public hostname on a domain you control, and route that hostname to the phone with a path rule for `/door2/*`. No inbound ports open on your network; the tunnel dials out to Cloudflare.
   * **Tailscale Funnel** — run `tailscale funnel` on the front-door machine to serve its tailnet address publicly, with the same `/door2/`-only forwarding in front of the phone.
3. Record that public address in the app's Public address field, and use it in your chatbot's configuration.

**The one rule that matters:** forward `/door2/` only. The phone's single listener serves both tunnels and relies on Tunnel 1 paths being reachable only from inside the tailnet. A front door that forwards everything would publish Tunnel 1 — the path filter at the front door is a security boundary, not a nicety.

> [accordion] Read this before you try Funnel on the phone itself
>
> **Android cannot host a Tailscale Funnel.** Funnel is a feature of the Tailscale command-line program, and there is no Tailscale CLI in the Android app — the phone's Tailscale app has no Funnel switch to turn on, and no setting in BunnyBridge can change that. (Tailscale's own Funnel documentation describes it as working on platforms that can run the Tailscale CLI.) This is why the front door lives on a computer: the computer runs the CLI, hosts the Funnel, and forwards to the phone over the tailnet. If a guide tells you to "just enable Funnel on your phone," it is describing a desktop — skip it and use the pattern above, Mode 1, or Mode 2 when it lands.
>
> Two one-time prerequisites live in the Tailscale admin console (a browser, not the phone): under **DNS**, enable **HTTPS certificates**; under **Access controls → Funnel**, add Funnel to your policy. Without them, the `tailscale funnel` command on your front-door machine will stop and tell you — follow its link, approve, and run it again.

## Mode 2 — the hosted relay (In development)

Mode 2 is the permanent version: a small relay run by Leverine that the phone **dials out** to and stays connected to. Your chatbot talks to the relay's public address with your Tunnel 2 token; commands ride the phone's own outbound connection back in, and results return the same way. For you it is one switch — no addresses to record, nothing to run on your network, and the phone still exposes no public listener of its own.

Mode 2 is **not available yet**. Because a hosted relay costs money to run every month, it will be offered as a **subscription** — **CAD \$2.99 a month, or CAD \$29.99 a year**, and your price holds for as long as your subscription stays active. It is not part of the CAD \$6.99 lifetime unlock, which covers the features that live on your phone (see the [pricing terms](https://docs.leverine.com/bunnybridge/index.md#price-in-one-paragraph) on the overview page). Until Mode 2 ships, use Mode 1 with any chatbot, or the self-hosted pattern above if you are technical and want a direct chatbot connection today. When Mode 2 arrives, the address it gives you is what goes in the app's **Public address** field, and the integration steps further up this page (OpenAPI import, MCP) apply unchanged.

## Tunnel 2 errors, quickly

| What you see | What it means |
| - | - |
| `403` with "door 2 is off" | The Tunnel 2 surface is off — Mode 1 (relay) is selected. Only the owner can change it (Status → Chatbot Access → Your own front door). A Tunnel 1 token will not help here — it never works on this surface. |
| `403` (other) | The token is wrong for this tunnel, revoked, or rotated past grace. Check you are using a Tunnel 2 token, on the `/door2/` paths. |
| `429` | Rate limit: 30 authenticated calls per minute per token, or 2 commands already running. The reply may carry `retry_after_s` — wait that long, then continue. Repeated 429s mean you are looping; stop and summarise instead. |
| Public address unreachable | The front door is down (Mode 2 connection dropped, or your front-door machine is off / its Funnel or tunnel stopped). The phone's Status screen shows Tunnel 2's recorded address and readiness. |

More in [Troubleshooting](https://docs.leverine.com/bunnybridge/troubleshooting.md), and the complete surface in the [API Reference](https://docs.leverine.com/bunnybridge/api-reference.md).

***

*Source: Leverine/Leverine-BunnyBridge\@902c77c — `docs/site/BunnyBridge/door2.html`.*


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.