Overview
The Telegram MCP service enables agents to:- Send messages to Telegram users
- Receive and process incoming messages
- Get chat information
- Manage group conversations
- Handle media files (documents, images, audio)
Setup
Prerequisites
- Telegram account
- Telegram Bot (created via BotFather)
- API token from BotFather
- Supabase database for persistence
1. Create a Telegram Bot
2. Configure Environment
Add to.env:
3. Docker Configuration
The Telegram MCP service runs in a separate Docker container:4. Start Service
API Usage
Send Message
Send Message with Buttons
Read Messages
Get Chat Information
Send Document
Send Photo
Agent Configuration
Enable Telegram Tools
Configure your agent to use Telegram:Webhook Handler
Set up a webhook to receive Telegram updates:Practical Examples
Customer Support Bot
Order Status Bot
Notification System
Error Handling
Common Issues
Retry Logic
Database Schema
Telegram messages are stored in Supabase:Monitoring
Health Check
Logs
Message Analytics
Rate Limiting
Telegram has rate limits:- 30 messages per second per chat
- 100 messages per second per bot
Best Practices
- Handle Errors Gracefully - Bot may lose access to chats
- Rate Limit - Don’t exceed Telegram’s rate limits
- Validate Input - Sanitize user input before processing
- Store Data - Save messages for audit trail
- Async Operations - Use async/await for performance
- Error Logging - Log all errors for debugging
- User Consent - Get permission before sending messages
- Message Format - Use HTML/Markdown for better formatting