Documentation Index
Fetch the complete documentation index at: https://cowswap-mintlify-audit-seo-quality-1775466652.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Telegram Bot Service
The Telegram Bot Service functions as a message consumer that processes notifications from RabbitMQ and routes them to subscribed Telegram users. The system handles formatting conversions, maintains subscription caches, and implements automatic retry mechanisms for failed deliveries.Core Responsibilities
The service manages three primary functions:- Consuming notifications from message queues
- Converting notification content into Telegram-compatible HTML format
- Distributing messages to all users subscribed to each account
How to Run
Development
Production
Docker
Configuration
| Setting | Purpose | Mandatory |
|---|---|---|
| TELEGRAM_SECRET | Bot authentication token | Yes |
| QUEUE_HOST | RabbitMQ hostname | No |
| DATABASE_HOST | PostgreSQL location | No |
/newbot.
Operational Architecture
The service operates through an infinite loop that establishes RabbitMQ connections and processes incoming notifications. When connection losses occur, automatic reconnection attempts trigger after 10-second intervals. Subscription caching reduces database strain: subscription data refreshes every 5 minutes, with lookups using account addresses as cache keys.Message Transformation Process
Notifications undergo multi-step conversion:- Markdown formatting
- HTML parsing via the
markedlibrary - Sanitization with DOMPurify (preserving only Telegram-supported tags)
- Delivery via Telegram Bot API
<b>, <i>, <u>, <s>, <a>, <code>, and <pre> tags.
Delivery Workflow
- Blockchain events trigger notification generation
- Notification enters the RabbitMQ queue
- The Telegram service retrieves subscribed chat IDs
- Content is formatted as HTML
- Messages are dispatched
- Successful processing is acknowledged back to the queue
Error Management
- Connection interruptions trigger automatic reconnection cycles
- Message delivery errors are logged without crashing the service
- Failed sanitization attempts include source markdown and problematic HTML in error reports
Subscription Operations
Subscriptions map Ethereum addresses to Telegram chat IDs. Users authenticate via wallet before providing chat IDs through the API service (not through the bot directly). The system automatically incorporates new subscriptions after cache expiration.Monitoring Output
Structured logging includes notifications about:- Consumer initialization
- Subscription lookups
- Message dispatching
- Connection status changes