Telegram Integration
Run Maestro as a Telegram bot for mobile access to your AI agents.
Prerequisites
Section titled “Prerequisites”- Telegram account
- Maestro installed and configured
-
Create a bot with BotFather
Open Telegram and message @BotFather:
/newbotFollow the prompts:
- Choose a name (e.g., “My Maestro Bot”)
- Choose a username (must end in
bot, e.g.,my_maestro_bot)
BotFather will give you a token like:
123456789:ABCdefGHIjklMNOpqrsTUVwxyz -
Add the token to your environment
Edit your
.envfile:Terminal window TELEGRAM_BOT_TOKEN=123456789:ABCdefGHIjklMNOpqrsTUVwxyz -
Start the bot
Terminal window # Dockerdocker compose up -d telegram# Or local developmentnpm run dev -
Test it
Open Telegram and message your bot:
/startThe bot should respond. Try a conversation:
You: Hello!Bot: Hi! I'm your Maestro assistant. How can I help?You: What's 25 * 47?Bot: 25 * 47 = 1,175
Bot Commands
Section titled “Bot Commands”The Telegram bot responds to regular messages. You can also set up commands via BotFather:
/setcommandsThen provide:
start - Start the bothelp - Show help messageclear - Clear conversation historycost - Show token usageGroup Chats
Section titled “Group Chats”The bot works in group chats too:
- Add the bot to a group
- Make it an admin (or disable privacy mode in BotFather)
- The bot responds to messages that mention it or reply to it
Privacy Mode
Section titled “Privacy Mode”By default, Telegram bots in groups only see:
- Messages that mention the bot
- Replies to the bot’s messages
- Commands
To see all messages, disable privacy mode in BotFather:
/setprivacySelect “Disable”.
Deployment
Section titled “Deployment”Docker Compose
Section titled “Docker Compose”The default docker-compose.yml includes a telegram service:
services: telegram: build: . environment: - ANTHROPIC_API_KEY - TELEGRAM_BOT_TOKEN volumes: - ./data:/app/data - ./projects:/app/projectsStart it:
docker compose up -d telegramRunning Alongside API
Section titled “Running Alongside API”You can run both Telegram and API services:
docker compose up -dThey share the same data directory and agent configurations.
Formatting
Section titled “Formatting”The bot supports Telegram’s markdown formatting:
- Bold:
**text**or__text__ - Italic:
*text*or_text_ Code:`code`- Code blocks:
```language\ncode\n```
The LLM’s responses are automatically formatted for Telegram.
Troubleshooting
Section titled “Troubleshooting”Bot doesn’t respond
Section titled “Bot doesn’t respond”- Check the token is correct in
.env - Check logs:
docker compose logs telegram - Verify the bot is running:
docker compose ps
”Unauthorized” error
Section titled “”Unauthorized” error”Your bot token is invalid. Get a new one from BotFather.
Messages not received in groups
Section titled “Messages not received in groups”Enable the bot as admin or disable privacy mode.
Slow responses
Section titled “Slow responses”- Check your network connection
- The Anthropic API might be slow
- Large context (long conversations) takes longer
Security
Section titled “Security”- Keep your bot token secret
- Don’t commit
.envto version control - Consider restricting who can use the bot (not built-in, requires code changes)
Rate Limits
Section titled “Rate Limits”Telegram has rate limits:
- ~30 messages per second to different chats
- ~1 message per second to the same chat
Maestro handles these automatically, but very high usage might hit limits.