Telegram Channel
The Telegram channel app is the reference implementation for OpenClawOS channels.
Overview
| Property | Value |
|---|---|
| Package | @openclawos/telegram |
| API | Telegram Bot API |
| Features | Groups, private chats, inline mode |
| Status | Production Ready |
Quick Start
1. Create a Bot
- Message @BotFather on Telegram
- Send
/newbotand follow the prompts - Copy the bot token
2. Configure
Or edit config.json:
{
"channels": {
"telegram": {
"enabled": true,
"botToken": "123456789:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"
}
}
}
3. Start
Your bot is now active!
Configuration
Basic
Multi-Account
{
"channels": {
"telegram": {
"enabled": true,
"accounts": {
"default": {
"botToken": "123:abc",
"name": "Main Bot"
},
"support": {
"botToken": "456:def",
"name": "Support Bot"
}
}
}
}
}
Advanced Options
{
"channels": {
"telegram": {
"enabled": true,
"botToken": "123:abc",
"allowUnmentionedGroups": false,
"allowedGroups": ["-1001234567890"],
"blockedUsers": ["123456789"]
}
}
}
| Option | Type | Description |
|---|---|---|
enabled |
boolean | Enable/disable channel |
botToken |
string | Bot API token |
allowUnmentionedGroups |
boolean | Respond in groups without @mention |
allowedGroups |
string[] | Whitelist of group IDs |
blockedUsers |
string[] | Blacklist of user IDs |
Features
Private Chats
Direct messages to your bot:
Group Chats
In groups, the bot responds to:
- Direct @mentions:
@YourBot what's the weather? - Replies to bot messages
- All messages (if
allowUnmentionedGroups: true)
Commands
Built-in commands:
| Command | Description |
|---|---|
/start |
Welcome message |
/help |
Help information |
/reset |
Reset conversation |
Markdown Formatting
Messages support Telegram Markdown:
File Attachments
The bot can send:
- Photos
- Documents
- Voice messages
- Videos
Architecture
┌─────────────────────────────────────────────────────────────────┐
│ Telegram App │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌──────────────┐ ┌─────────────────┐ │
│ │ Telegram │───▶│ Message │───▶│ Kernel │ │
│ │ Bot API │ │ Handler │ │ (IPC Queue) │ │
│ └─────────────┘ └──────────────┘ └─────────────────┘ │
│ ▲ │ │
│ │ │ │
│ ┌─────┴─────────────────────────────────────────┐ │
│ │ Send Handler │ │
│ │ (Receives message_sending hook) │ │
│ └───────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
Message Flow
Inbound
- User sends message to bot
- Telegram API delivers to app via long polling
- App extracts chat ID and text
- App calls
agent.queuevia IPC - Kernel processes with agent
Outbound
- Agent generates response
- Kernel fires
message_sendinghook - App receives hook event
- App calls Telegram
sendMessageAPI - User receives message
Session Keys
Format: telegram:{chat_id}
Examples:
telegram:123456789- Private chattelegram:-1001234567890- Group chat
Error Handling
Rate Limits
Telegram limits:
- 30 messages/second per bot
- 1 message/second per chat
The app handles rate limits automatically with exponential backoff.
Network Errors
Connection errors trigger automatic reconnection with backoff.
Blocked Users
If a user blocks the bot, send attempts are silently dropped.
Privacy Mode
In groups, bots only receive:
- Messages starting with
/ - Messages mentioning the bot
- Replies to bot messages
To receive all messages, disable privacy mode via BotFather:
- Message @BotFather
- Send
/setprivacy - Select your bot
- Choose
Disable
Monitoring
Health Check
Logs
Source Code
Location: apps/telegram/
Key files:
src/app.ts- Main applicationsrc/handlers/- Message handlersopenclawos.manifest.json- Package manifest
Troubleshooting
Bot not responding
- Check token:
openclaw channels status telegram - Verify bot is not disabled in BotFather
- Check logs for errors
Messages not delivered
- Check if user blocked the bot
- Verify group permissions
- Check rate limit status
Group messages ignored
- Enable
allowUnmentionedGroupsor use @mentions - Disable privacy mode in BotFather
- Check
allowedGroupswhitelist