In OpenClaw, how do you add a second account to a channel already running one, such as a second Telegram bot, and what commonly breaks?
answer
- one channel, many account ids
- channels.<channel>.accounts map
- top-level values get promoted
- env tokens reach only default
- duplicate tokens and blank --account
basics
~20 sAdd it under channels.<channel>.accounts with its own id, for example openclaw channels add --channel telegram --account alerts --token; OpenClaw promotes the old top-level settings into the accounts map, and env tokens keep applying only to the default account.
solid answer
~40 sEach channel can hold several accounts under `channels.<channel>.accounts.<id>`, and `default` is the one used whenever an `accountId` is omitted. `openclaw channels add --channel telegram --account alerts --token <token>` adds one; if the channel was still a single-account top-level config, OpenClaw first **promotes** those top-level values into the accounts map (usually `accounts.default`) so the original bot keeps working. What breaks: environment tokens such as `TELEGRAM_BOT_TOKEN` or `DISCORD_BOT_TOKEN` only resolve for the default account, so a named account needs its own `botToken`, `tokenFile` or `token`; two Discord accounts resolving to the same token run only one monitor; WhatsApp accounts each need their own `channels login --account`; and a blank `--account` is rejected rather than silently meaning default. Mixed shapes are repaired with `openclaw doctor --fix`.
code
bash · 8 lines# Second Telegram bot with its own token
openclaw channels add --channel telegram --account alerts --token <alerts-bot-token>
# Second WhatsApp number: its own session, its own QR
openclaw channels login --channel whatsapp --account work
# Check both accounts live
openclaw channels status --probego deeper
Recall that accounts live under channels.<channel>.accounts with an id, and that default is used when no account is named.
Explain promotion of top-level values, per-account credentials, and why environment tokens only reach the default account.
Debug multi-account setups: duplicate Discord tokens, an unclear Telegram default, per-account Signal transports, mixed config shapes and doctor --fix.
Decide when separate accounts beat one shared bot, for example isolating alerts or work traffic, and what each extra credential or linked device adds to operate and rotate.
## The account model In OpenClaw a **channel** (Telegram, WhatsApp, Discord...) can carry several **accounts**, each with an `accountId`. The pattern is shared across channels that support `accounts`: ```json { "channels": { "telegram": { "accounts": { "default": { "name": "Primary bot", "botToken": "<primary-token>" }, "alerts": { "name": "Alerts bot", "tokenFile": "/home/ops/.secrets/alerts-bot.txt" } } } } } ``` - `default` is used when an `accountId` is omitted, by the CLI and by routing. - Base channel settings apply to every account unless an account overrides them. - Typical reasons: a personal and a work Discord bot, a second WhatsApp number, or a separate Telegram bot that only posts alerts. ## Adding the second account 1. Run `openclaw channels add --channel telegram --account alerts --token <token>` (or edit `openclaw.json`). 2. If the channel was configured as a single account at the top level, OpenClaw **promotes** those top-level values into the accounts map before writing the new account, so the first bot keeps working. Most channels move them into `accounts.default`; promotion reuses an existing named account when there is exactly one, or the one `defaultAccount` points at. 3. For device-linked channels, link each account separately: `openclaw channels login --channel whatsapp --account work` gives that account its own session under `credentials/whatsapp/work/`. 4. Verify with `openclaw channels status --probe`. `add`, `login`, `logout` and `remove` all take `--account <id>`; omitting it selects the default account, and an explicitly **blank** value is rejected so an unset shell variable cannot quietly act on an account you did not name. ## What commonly breaks - **Environment tokens reach only the default account.** `TELEGRAM_BOT_TOKEN`, `DISCORD_BOT_TOKEN` and the Slack token variables resolve for `default` only. A named account with no `botToken`, `tokenFile` (Telegram) or `token` (Discord) has no credential. - **Duplicate Discord tokens.** If two enabled Discord accounts resolve to the same bot token, OpenClaw starts one monitor for it and reports the other disabled as a duplicate bot token. - **Unclear default.** With two or more Telegram accounts and no `accounts.default`, set `channels.telegram.defaultAccount`; otherwise OpenClaw falls back to the first normalized id and `openclaw doctor` warns. - **Policy inheritance surprises.** An omitted account `dmPolicy` or `groupPolicy` inherits the channel root on Telegram, Signal, Discord, Slack and iMessage; WhatsApp named accounts first inherit from `accounts.default`. The policies themselves are an access-control topic, but the inheritance order is why a new account can behave differently from what you expected. - **Per-account transports.** A Signal named account owns its own `transport`; it does not inherit the top-level one, which belongs to the implicit default account. Slack HTTP-mode accounts each need a distinct `webhookPath`. - **Mixed shapes.** Named accounts plus leftover top-level single-account values is an ambiguous config; `openclaw doctor --fix` moves the account-scoped values into the promoted account. ## Removing an account again - `openclaw channels remove --channel telegram --account alerts` asks to **disable** the account and keeps its config. - Adding `--delete` removes the config entries without prompting. - For runtime-backed channels, `remove` first asks the running Gateway to stop that account, so the old listener does not keep answering until the next restart. ## Accounts versus agents Adding an account does not decide which agent answers it. Existing channel-only bindings keep matching the default account, and non-interactive `channels add` never creates bindings. Sending each account to a different agent is a routing question handled with bindings that match on `accountId`, covered with multi-agent routing. ## Checklist | Step | Command or key | |---|---| | Add the account | `openclaw channels add --channel <ch> --account <id> ...` | | Give it its own credential | `accounts.<id>.botToken` / `tokenFile` / `token` | | Link device channels | `openclaw channels login --channel whatsapp --account <id>` | | Make the default explicit | `accounts.default` or `defaultAccount` | | Repair mixed shapes | `openclaw doctor --fix` | | Verify | `openclaw channels status --probe` |
- Why does `openclaw channels add --account "$ACCOUNT"` fail when ACCOUNT is unset, instead of using the default account?A blank `--account` is rejected on purpose for `add`, `login`, `logout` and `remove`. Falling back to `default` would let an unset shell variable silently modify or log out an account you never named. Omit the flag entirely when you mean the default account.
- You configured two Discord accounts but status shows one disabled as a duplicate bot token. What happened?Both accounts resolved to the same bot token, often because one lacks its own `token` and picked up `DISCORD_BOT_TOKEN`. OpenClaw runs only one monitor per token: a config-sourced token wins over the env fallback, otherwise the first enabled account. Give each account its own token and application ID.
- TELEGRAM_BOT_TOKEN gives a token to every Telegram account that lacks one.
- Adding a second account overwrites the first account's top-level settings.
- Two WhatsApp accounts can share one QR login and one session folder.
- A blank --account value safely falls back to the default account.
- Adding an account automatically routes it to its own agent.