Overview
The Telegram channel uses the grammY library to connect via the Telegram Bot API. It’s simpler to set up than WhatsApp (no QR codes) and supports both private chats and groups.Installation
Run the/add-telegram skill in Claude Code:
- Install the Telegram channel code
- Add required dependencies (
grammy) - Guide you through bot creation
- Configure authentication
- Register your first chat
Creating a Telegram Bot
Create New Bot
Send
/newbot and follow the prompts:- Bot name: Something friendly (e.g., “Andy Assistant”)
- Bot username: Must end with “bot” (e.g., “andy_ai_bot”)
Configuration
Add the bot token to.env:
The channel auto-enables when
TELEGRAM_BOT_TOKEN is set. No additional configuration needed.Group Privacy Settings
Skip this if you only want trigger-based responses (users must @mention the bot).
Chat Registration
Getting the Chat ID
The bot has a built-in/chatid command to find chat IDs:
Registering a Main Chat
Main chats respond to all messages (no trigger required):Registering Additional Chats
Additional chats require the trigger pattern:How It Works
Connection
- Telegram channel reads
TELEGRAM_BOT_TOKENfrom environment - Creates grammY bot instance
- Sets up message handlers and commands
- Starts long polling to receive updates
Message Handling
The channel automatically translates Telegram-specific features: @Mention Translation Telegram @mentions (like@andy_ai_bot) are automatically converted to NanoClaw’s trigger format:
- Private chats: Sender name used as chat name
- Groups: Group title used as chat name
- Supergroups: Treated same as groups
Built-in Commands
| Command | Purpose |
|---|---|
/chatid | Get the chat ID for registration |
/ping | Check if the bot is online |
Troubleshooting
Bot Not Responding
Bot Only Responds to @Mentions in Groups
This is the default behavior when Group Privacy is enabled. To fix:@BotFather→/mybots→ select bot → Bot Settings → Group Privacy → Turn off- Remove and re-add the bot to the group
/chatid Command Not Working
Invalid Token Error
The token format should be<number>:<alphanumeric>. If you get “invalid token”:
- Go back to
@BotFather - Send
/mybots→ select your bot → API Token - Copy the full token (including the colon)
- Update
.envand sync:mkdir -p data/env && cp .env data/env/env - Restart:
npm run build && launchctl kickstart -k gui/$(id -u)/com.nanoclaw
Implementation Details
Dependencies
grammy- Modern Telegram Bot API framework
JID Format
- Private chats:
tg:<user-id>(e.g.,tg:123456789) - Groups:
tg:<group-id>(e.g.,tg:-1001234567890)
Self-Registration Code
TELEGRAM_BOT_TOKEN is set.
Message Processing
Next Steps
Add Slack
Add Slack as another channel
Channel Overview
Learn about the channel system