Caricamento in corso...
Caricamento in corso...
Last synced: Today, 22:00
Technical reference for the OpenClaw framework. Real-time synchronization with the official documentation engine.
Use this file to discover all available pages before exploring further.
Production-ready for bot DMs and groups via grammY. Long polling is the default mode; webhook mode is optional.
Default DM policy for Telegram is pairing.
Cross-channel diagnostics and repair playbooks.
Full channel config patterns and examples.
textRun `/newbot`, follow prompts, and save the token.
textEnv fallback: `TELEGRAM_BOT_TOKEN=...` (default account only). Telegram does **not** use `openclaw channels login telegram`; configure token in config/env, then start gateway.
```
textPairing codes expire after 1 hour.
Add the bot to a group
Add the bot to your group, then set `channels.telegram.groups` and `groupPolicy` to match your access model.
note
Token resolution order is account-aware. In practice, config values win over env fallback, and `TELEGRAM_BOT_TOKEN` only applies to the default account.
Telegram side settings
Access control and activation
`channels.telegram.dmPolicy` controls direct message access:
text* `pairing` (default)
* `allowlist` (requires at least one sender ID in `allowFrom`)
* `open` (requires `allowFrom` to include `"*"`)
* `disabled`
`dmPolicy: "open"` with `allowFrom: ["*"]` lets any Telegram account that finds or guesses the bot username command the bot. Use it only for intentionally public bots with tightly restricted tools; one-owner bots should use `allowlist` with numeric user IDs.
`channels.telegram.allowFrom` accepts numeric Telegram user IDs. `telegram:` / `tg:` prefixes are accepted and normalized.
In multi-account configs, a restrictive top-level `channels.telegram.allowFrom` is treated as a safety boundary: account-level `allowFrom: ["*"]` entries do not make that account public unless the effective account allowlist still contains an explicit wildcard after merging.
`dmPolicy: "allowlist"` with empty `allowFrom` blocks all DMs and is rejected by config validation.
Setup asks for numeric user IDs only.
If you upgraded and your config contains `@username` allowlist entries, run `openclaw doctor --fix` to resolve them (best-effort; requires a Telegram bot token).
If you previously relied on pairing-store allowlist files, `openclaw doctor --fix` can recover entries into `channels.telegram.allowFrom` in allowlist flows (for example when `dmPolicy: "allowlist"` has no explicit IDs yet).
For one-owner bots, prefer `dmPolicy: "allowlist"` with explicit numeric `allowFrom` IDs to keep access policy durable in config (instead of depending on previous pairing approvals).
Common confusion: DM pairing approval does not mean "this sender is authorized everywhere".
Pairing grants DM access. If no command owner exists yet, the first approved pairing also sets `commands.ownerAllowFrom` so owner-only commands and exec approvals have an explicit operator account.
Group sender authorization still comes from explicit config allowlists.
If you want "I am authorized once and both DMs and group commands work", put your numeric Telegram user ID in `channels.telegram.allowFrom`; for owner-only commands, make sure `commands.ownerAllowFrom` contains `telegram:<your user id>`.
### Finding your Telegram user ID
Safer (no third-party bot):
1. DM your bot.
2. Run `openclaw logs --follow`.
3. Read `from.id`.
Official Bot API method:
```bash}
curl "https://api.telegram.org/bot<bot_token>/getUpdates"
```
Third-party method (less private): `@userinfobot` or `@getidsbot`.
Two controls apply together:
text1. **Which groups are allowed** (`channels.telegram.groups`)
* no `groups` config:
* with `groupPolicy: "open"`: any group can pass group-ID checks
* with `groupPolicy: "allowlist"` (default): groups are blocked until you add `groups` entries (or `"*"`)
* `groups` configured: acts as allowlist (explicit IDs or `"*"`)
2. **Which senders are allowed in groups** (`channels.telegram.groupPolicy`)
* `open`
* `allowlist` (default)
* `disabled`
`groupAllowFrom` is used for group sender filtering. If not set, Telegram falls back to `allowFrom`.
`groupAllowFrom` entries should be numeric Telegram user IDs (`telegram:` / `tg:` prefixes are normalized).
Do not put Telegram group or supergroup chat IDs in `groupAllowFrom`. Negative chat IDs belong under `channels.telegram.groups`.
Non-numeric entries are ignored for sender authorization.
Security boundary (`2026.2.25+`): group sender auth does **not** inherit DM pairing-store approvals.
Pairing stays DM-only. For groups, set `groupAllowFrom` or per-group/per-topic `allowFrom`.
If `groupAllowFrom` is unset, Telegram falls back to config `allowFrom`, not the pairing store.
Practical pattern for one-owner bots: set your user ID in `channels.telegram.allowFrom`, leave `groupAllowFrom` unset, and allow the target groups under `channels.telegram.groups`.
Runtime note: if `channels.telegram` is completely missing, runtime defaults to fail-closed `groupPolicy="allowlist"` unless `channels.defaults.groupPolicy` is explicitly set.
Example: allow any member in one specific group:
```json5}
{
channels: {
telegram: {
groups: {
"-1001234567890": {
groupPolicy: "open",
requireMention: false,
},
},
},
},
}
```
Example: allow only specific users inside one specific group:
```json5}
{
channels: {
telegram: {
groups: {
"-1001234567890": {
requireMention: true,
allowFrom: ["8734062810", "745123456"],
},
},
},
},
}
```
<Warning>
Common mistake: `groupAllowFrom` is not a Telegram group allowlist.
* Put negative Telegram group or supergroup chat IDs like `-1001234567890` under `channels.telegram.groups`.
* Put Telegram user IDs like `8734062810` under `groupAllowFrom` when you want to limit which people inside an allowed group can trigger the bot.
* Use `groupAllowFrom: ["*"]` only when you want any member of an allowed group to be able to talk to the bot.
</Warning>
Group replies require mention by default.
textMention can come from:
* native `@botusername` mention, or
* mention patterns in:
* `agents.list[].groupChat.mentionPatterns`
* `messages.groupChat.mentionPatterns`
Session-level command toggles:
* `/activation always`
* `/activation mention`
These update session state only. Use config for persistence.
Persistent config example:
```json5}
{
channels: {
telegram: {
groups: {
"*": { requireMention: false },
},
},
},
}
```
Getting the group chat ID:
* forward a group message to `@userinfobot` / `@getidsbot`
* or read `chat.id` from `openclaw logs --follow`
* or inspect Bot API `getUpdates`
Runtime behavior
- Telegram is owned by the gateway process.
- Routing is deterministic: Telegram inbound replies back to Telegram (the model does not pick channels).
- Inbound messages normalize into the shared channel envelope with reply metadata and media placeholders.
- Group sessions are isolated by group ID. Forum topics append text
:topic:<threadId> to keep topics isolated.
- DM messages can carry text
message_thread_id; OpenClaw routes them with thread-aware session keys and preserves thread ID for replies.
- Long polling uses grammY runner with per-chat/per-thread sequencing. Overall runner sink concurrency uses text
agents.defaults.maxConcurrent.
- Long polling is guarded inside each gateway process so only one active poller can use a bot token at a time. If you still see text
getUpdates 409 conflicts, another OpenClaw gateway, script, or external poller is likely using the same token.
- Long-polling watchdog restarts trigger after 120 seconds without completed text
getUpdates liveness by default. Increase textchannels.telegram.pollingStallThresholdMs only if your deployment still sees false polling-stall restarts during long-running work. The value is in milliseconds and is allowed from text30000 to text600000; per-account overrides are supported.
- Telegram Bot API has no read-receipt support (text
sendReadReceipts does not apply).
Feature reference
Error reply controls
When the agent encounters a delivery or provider error, Telegram can either reply with the error text or suppress it. Two config keys control this behavior:
Key Values Default Description textchannels.telegram.errorPolicy textreply, textsilent textreply textreply sends a friendly error message to the chat. textsilent suppresses error replies entirely. textchannels.telegram.errorCooldownMs number (ms) text60000 Minimum time between error replies to the same chat. Prevents error spam during outages.
Per-account, per-group, and per-topic overrides are supported (same inheritance as other Telegram config keys).
json5{
channels: {
telegram: {
errorPolicy: "reply",
errorCooldownMs: 120000,
groups: {
"-1001234567890": {
errorPolicy: "silent", // suppress errors in this group
},
},
},
},
}
Troubleshooting
More help: Channel troubleshooting.
Configuration reference
Primary reference: Configuration reference - Telegram.
note
Multi-account precedence: when two or more account IDs are configured, set `channels.telegram.defaultAccount` (or include `channels.telegram.accounts.default`) to make default routing explicit. Otherwise OpenClaw falls back to the first normalized account ID and `openclaw doctor` warns. Named accounts inherit `channels.telegram.allowFrom` / `groupAllowFrom`, but not `accounts.default.*` values.
Related
© 2024 TaskFlow Mirror
Powered by TaskFlow Sync Engine