---
description: Interactively guide MulmoBridge Relay setup — Cloudflare Workers deploy, platform secrets, and MulmoClaude connection. Respond in the user's language.
---

# Setup MulmoBridge Relay

Guide the user through Relay setup following `docs/message_apps/relay/`. Use the language-appropriate version (README.md for English, README.ja.md for Japanese) based on the user's language.

## Step 1: Prerequisites

1. Check MulmoClaude is running (`lsof -i :3001 -sTCP:LISTEN`). If not, ask the user to run `yarn dev` first.
2. Check wrangler is installed (`which wrangler`). If not:
   ```bash
   npm install -g wrangler
   ```
3. Check wrangler is authenticated (`wrangler whoami`). If not, tell the user to run:
   ```
   ! wrangler login
   ```
   (The `!` prefix runs it in the user's terminal since it requires browser interaction.)
4. **workers.dev subdomain**: If this is the user's first time using Workers, they need a `workers.dev` subdomain. Tell them to open the Cloudflare dashboard → **Compute** → **Workers & Pages**. Opening this page for the first time automatically creates the subdomain.

## Step 2: Deploy the Relay

Tell the user to run:
```
! cd packages/relay && wrangler deploy
```

Wait for the user to confirm. Ask them to paste the output URL (e.g., `https://mulmobridge-relay.xxx.workers.dev`).

Save the URL — you'll need it for Step 4.

## Step 3: Set secrets

### RELAY_TOKEN

Tell the user to run the following in their terminal (token generation + secret registration). The user should keep the generated token — it will also be needed for `.env` in Step 4.

```bash
# Generate token, save to clipboard/notepad, then register as secret
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
cd packages/relay && wrangler secret put RELAY_TOKEN
```

### Platform secrets

Ask the user which platforms they want to use. For each selected platform:

#### LINE
Tell the user to run (must be in `packages/relay` directory):
```
! cd packages/relay && wrangler secret put LINE_CHANNEL_SECRET
! cd packages/relay && wrangler secret put LINE_CHANNEL_ACCESS_TOKEN
```
And enter their LINE Developers Console values.

Then tell them to update their LINE webhook URL to:
```
https://<relay-url>/webhook/line
```

#### Telegram
Tell the user to run:
```
! wrangler secret put TELEGRAM_BOT_TOKEN
! wrangler secret put TELEGRAM_WEBHOOK_SECRET
```

Then set the webhook:
```bash
curl "https://api.telegram.org/bot<TOKEN>/setWebhook?url=https://<relay-url>/webhook/telegram&secret_token=<SECRET>"
```

## Step 4: Configure MulmoClaude

Tell the user to add the Relay connection to `.env` themselves. Both the URL (from Step 2) and the token (generated in Step 3) are needed:

```bash
echo "" >> .env
echo "# MulmoBridge Relay" >> .env
echo "RELAY_URL=wss://<relay-url>/ws" >> .env
echo "RELAY_TOKEN=<token-from-step-3>" >> .env
```

**Important**: The token value was generated by the user in Step 3. Do NOT generate a new token — ask the user to use the same value they registered with `wrangler secret put`.

## Step 5: Verify

1. Check the health endpoint:
   ```bash
   curl https://<relay-url>/health
   ```
   Confirm the configured platforms show `true`.

2. Restart MulmoClaude:
   ```bash
   # Tell user to restart yarn dev
   ```

3. Send a test message from the configured platform.

4. Check server logs for relay connection and message delivery.

## Key pitfalls to highlight

- `wrangler secret put` is interactive — the user must run it themselves (use `!` prefix), and must be run from `packages/relay` directory
- `wrangler deploy` and `wrangler login` require browser interaction
- **workers.dev subdomain**: First-time Workers users must open the Workers & Pages dashboard to auto-create their subdomain before `wrangler deploy` will succeed
- The RELAY_TOKEN must be identical in both the Cloudflare secret and the `.env` file
- **Token management**: Let the user generate and manage the token in their own terminal. Do NOT generate it in Claude's shell — this avoids the user having to copy a value back from the conversation
- LINE webhook URL must be the Relay URL, not the old ngrok URL
- Durable Objects work on the free plan when using `new_sqlite_classes` in `wrangler.toml` (the default in this project)
