Connect Telegram to OpenClaw and approve your first pairing
Connect a Telegram test bot to an existing Gateway, verify account ownership, approve your own DM request, and check channel status after disabling it.
Before you start · 1. Create the token in BotFather · 2. Put the token and DM policy in the Gateway config
At a glance
Start with an OpenClaw Gateway that already supports a working chat session. Connect your own Telegram test bot using the default account and DM pairing: confirm its existing agent owner, check the channel, then approve only your request. Group authorization is configured separately, and approving a DM does not open group access.
Workflow
Layer 1: token and policy
Check the BotFather handle, save the token and keep dmPolicy set to pairing.
Layer 2: channel status
Bind the account to an existing agent, then check its live state with channels status --probe.
Layer 3: pairing and groups
Review and approve your own pending request in the Control UI. Manage group permissions separately.
Before you start
- OpenClaw is installed and the Gateway supports a working chat session. You know how to manage it and can edit ~/.openclaw/openclaw.json. Save a configuration copy before changing it.
- You own a Telegram account and may create a test bot with @BotFather. Store the token on a controlled local machine, outside chats, tickets, screenshots and version control.
- Identify a real existing agent ID and the intended Telegram account ID. The example applies only after you confirm that default is the target account. Do not copy it into an existing multi-account setup.
1. Create the token in BotFather
Open @BotFather in Telegram and confirm that the handle matches exactly. Send /newbot, follow the prompts, and save the token. If it leaks, stop configuration and deal with the leak first. Create only your own test bot and use no one else's token.
2. Put the token and DM policy in the Gateway config
Edit ~/.openclaw/openclaw.json and merge the sample channels.telegram section into the existing configuration, preserving other channels. Set enabled to true and dmPolicy to pairing. Use botToken or point tokenFile at a regular file containing the saved token. tokenFile takes precedence over botToken, and symlinks are rejected. This example uses tokenFile and includes no token. Telegram does not use openclaw channels login telegram.
3. Add an agent ownership binding if needed
Confirm the existing agent ID and target account ID. Only when the target is default, replace the agent placeholder in the sample binding with the real existing agent ID and append it to bindings, preserving other entries. An account without a resolvable agent owner is blocked. After changing the binding, run openclaw gateway restart. This restarts the entire Gateway, so schedule it around use of other channels.
4. Verify the channel
On the Gateway host, run openclaw channels list to check configured accounts, then openclaw channels status --probe to check Telegram. If the Gateway is unreachable, status may show a configuration-only summary, which does not establish connectivity. Check for token errors or a missing-owner block. If the channel is not ready, diagnose it before pairing.
5. Approve the first DM
Send the bot a message from your own Telegram account to create a pending request. In the Control UI, open Settings → Channels → DM access requests. Filter by channel or account, review the sender ID and metadata, and choose Approve only after confirming it is you. Messages from unknown senders are not processed before approval, and pairing codes expire after 1 hour. Once DM access approved appears, do not approve again, even if the notification fails. Check the access status first. The first approval may also show an explicit command-owner option; select it only if you need that authority.
6. Check one reply
After approval, send "Introduce yourself in one sentence" and check for a reply. Record DM connectivity only when a real reply arrives. If none appears, keep the probe and request status and follow the official troubleshooting path. This task adds no group. DM approval grants DM access only; group access and command-owner authority need separate checks.
7. How to stop or roll back
To disable the example channel, set channels.telegram.enabled to false, run openclaw gateway restart, then run openclaw channels status --probe and check that no Telegram account continues running. Restoring dmPolicy or group settings alone does not disable the channel. In a multi-account environment, check the scope before stopping other accounts. Restoring a configuration copy reverts configuration only; it does not revoke stored DM approvals.
Original example
Synthetic example: configure the default account for your own demo_notes_bot. First confirm the target account ID is default and identify a real existing Gateway agent. The token-file path and agent ID are placeholders to replace. Merge this into the existing configuration; append the binding without replacing existing entries:
{
channels: {
telegram: {
enabled: true,
tokenFile: "/path/to/telegram-token.txt",
dmPolicy: "pairing"
}
},
bindings: [
{ agentId: "<EXISTING_AGENT_ID>", match: { channel: "telegram", accountId: "default" } }
]
}
Run openclaw gateway restart, then check with openclaw channels status --probe. Send a DM, confirm the sender is you under Settings → Channels → DM access requests, and approve. Send another message and check its actual reply. After the exercise, set enabled to false, restart, and verify the channel stopped. This illustrates configuration and checking, with no real account, token or observed output.
Completion checks
- The target account and existing agent IDs are confirmed, with existing bindings and other channels preserved.
- channels status --probe returns real channel checks, not only an unreachable-Gateway configuration summary.
- Only your own DM request was approved and a real reply arrived afterwards; DM approval was not treated as group access.
- After disabling the test channel and restarting, no Telegram account continues running. Configuration rollback and stored DM approval are treated separately.
Limits
- This guide covers default-account DM setup, not multi-account migration, group authorization, webhooks, media or the Mini App.
- The CLI also supports openclaw pairing list telegram and openclaw pairing approve telegram <CODE>, but it bootstraps the first command owner if none exists. This guide uses the Control UI so that this added authority is an explicit choice.
- tokenFile must be a regular file. The default-account TELEGRAM_BOT_TOKEN environment fallback does not apply to named accounts.
- DM approval does not automatically grant group access. Group IDs and sender IDs are not interchangeable.
Verification scope
Written from the OpenClaw official documentation read for this batch. Telegram login, Gateway installation or operation, product API calls, uploads and generated output were not tested. The sample illustrates configuration and completion checks.
Article sources
Original editorial content; official descriptions and checking suggestions are distinguished.