Skip to main content

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

Example API token:

2. Configure Environment

Add to .env:

3. Docker Configuration

The Telegram MCP service runs in a separate Docker container:

4. Start Service

Verify service is running:

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
Implement rate limiting:

Best Practices

  1. Handle Errors Gracefully - Bot may lose access to chats
  2. Rate Limit - Don’t exceed Telegram’s rate limits
  3. Validate Input - Sanitize user input before processing
  4. Store Data - Save messages for audit trail
  5. Async Operations - Use async/await for performance
  6. Error Logging - Log all errors for debugging
  7. User Consent - Get permission before sending messages
  8. Message Format - Use HTML/Markdown for better formatting

Next Steps

Gmail Integration

Set up email capabilities.

API Reference

Full API documentation.