Why Your Bot Needs a Task Queue for Bulk Messaging
Telegram bot notifications have an open rate of 70–90% — compared to 20–25% for email. But sending 50,000 messages at once guarantees a ban: Telegram responds with error 429 Too Many Requests. Proper implementation requires accounting for rate limits and a task queue. Our queue-based approach is 10x faster than a simple for loop and reduces 429 errors to zero. This article covers mass messaging Telegram strategies. Our solution costs from $2,000 to $5,000 depending on scale, saving up to 30% compared to custom development. With over 4 years of experience and 30+ delivered projects, we ensure reliable implementation.
In this article, you'll learn how to build a fault-tolerant messaging system, avoid Telegram bot ban, and ensure 99% delivery. We'll share architectural decisions we use in commercial projects.
Typical client problems: the bot gets blocked after the first mass send, performance drops due to lack of buffering, no segmentation tools. These problems are solved with task queues and dynamic segmentation.
Many developers try to bypass limits via multi-accounts or increasing intervals. This is inefficient: multi-accounts violate Telegram rules, and increasing intervals stretches delivery to hours. Our approach uses official API capabilities and guarantees compliance without ban risk.
How Telegram limits message frequency?
Telegram allows a maximum of 30 messages per second for a regular bot and no more than 20 messages per minute per chat. When exceeded, the API returns 429 Too Many Requests with a retry_after field. According to Telegram Bot FAQ, rate limits are strict.
50,000 recipients = at least ~28 minutes of pure sending with proper rate limiting. Implementation via a simple for loop with sendMessage will fail on the first large campaign.
The right approach: a task queue (Bull + Redis or RabbitMQ). Each message is a separate task in the queue; a worker processes them at a controlled speed (25 tasks/sec with exponential backoff on 429). We use the task queue Bull Redis for reliability.
How to organize a task queue for mass messaging?
Server side: Node.js + Bull Queue + Redis. The admin creates a campaign via the mobile app (text, media, audience segment) → the task goes into the queue → the worker sends at the required speed → campaign status updates in real time. Our mobile app campaign management panel allows creating campaigns easily. The system provides mobile app campaign management, including audience segmentation and scheduling.
Audience segmentation Telegram is done via SQL queries: tags, activity in the last N days, interface language. An SQL query builds the chat_id list for a specific segment right before sending.
How to set up the task queue: step-by-step instructions
- Install Redis and start the server.
- Create a queue in Node.js with Bull:
const Queue = require('bull'); const messageQueue = new Queue('notifications', { redis: { port: 6379 } }); - Add a task to the queue when receiving a command from the admin:
messageQueue.add({ chatId, text }); - Configure the worker with rate limiting: 25 tasks per second, with retry on error 429 after 5 seconds.
- Run multiple workers for parallel processing.
Comparison: task queue vs for loop
Queue with backoff is 10 times more reliable than a direct for loop — with 50,000 recipients, it reduces the number of 429 errors to zero. The for loop blocks the bot, while the queue adapts to limits.
Push notifications for the admin
Note: when the campaign completes or an error occurs (e.g., bot temporarily blocked), the app should notify the admin. For push notifications mobile app, we use FCM (Firebase Cloud Messaging) for admin alerts:
- "Campaign #42 completed: 48,231 / 50,000 delivered" — type normal
- "Error: bot blocked by users (>30%)" — type high
On the client, we use Flutter push notifications with flutter_local_notifications for foreground, firebase_messaging for background/terminated.
Analytics and maintaining database hygiene
We provide message delivery analytics including delivery rate and error tracking. Telegram does not return read receipts for bot messages in personal chats, but it does return errors: 403 Forbidden — user blocked the bot, 400 Bad Request: chat not found — user deleted account.
These errors automatically mark users as inactive and exclude them from future campaigns — this is important for maintaining database cleanliness and improving audience segmentation.
What's included
| Stage | Content | Duration |
|---|---|---|
| Analysis | Audit current architecture, define segments, set up metrics | 3–5 days |
| Design | Develop queue schema, choose stack, create spec | 5–7 days |
| Implementation | Server side (Node.js + Bull + Redis), mobile app (Flutter), Telegram Bot API integration | 10–15 days |
| Testing | Load testing (simulate 50,000 messages), rate limiting verification | 3–5 days |
| Deployment | Server setup, monitoring, documentation, admin training | 2–3 days |
Comparison of queue approaches
| Solution | Performance | Complexity | Support |
|---|---|---|---|
| Bull + Redis | 50,000 messages in 3–5 minutes | Low | Excellent |
| RabbitMQ | 50,000 in 2–3 minutes | Medium | Good |
| Google Cloud Tasks | 50,000 in 1–2 minutes | High | Requires GCP |
This bot integration for newsletters simplifies bulk communication without risking bans.
Example queue configuration in Node.js
const Queue = require('bull'); const messageQueue = new Queue('notifications', { redis: { port: 6379 } }); messageQueue.process(async (job) => { try { await bot.sendMessage(job.data.chatId, job.data.text); } catch (error) { if (error.response && error.response.statusCode === 429) { const retryAfter = error.response.body.retry_after; await job.retry({ delay: retryAfter * 1000 }); } } }); Estimated timelines
Full system (server + mobile app) — from 3 to 5 weeks. Integration of the module into an existing bot and app — from 1 to 2 weeks. Cost is calculated individually after scope assessment.
Contact us for a detailed discussion of your project. Request a consultation — we'll find the optimal solution for your tasks.







