Why Your Telegram Bot Gets Banned (And How to Stop It)
You build a bot. You test it locally, and it works perfectly. Then you deploy it to a group with 5,000 members or start sending out notifications, and suddenly-silence. Or worse, your account gets restricted. This isn’t bad luck; it’s usually a collision with Telegram’s rate limits, which are the invisible walls keeping spam at bay but often crushing legitimate automation.
Since launching its public Bot API in June 2015, Telegram has grown to over 700 million monthly active users. With that scale comes strict enforcement. If you ignore these limits, you’ll hit HTTP 429 “Too Many Requests” errors, get throttled, or face permanent bans. The goal of this guide is simple: help you keep your bot running smoothly without triggering Telegram’s automated defenses.
The Hard Numbers: What Are the Actual Limits?
Telegram doesn’t publish every single limit in one neat table, but community data and official documentation give us a clear picture by 2026. Here are the three critical ceilings you must respect:
- Global Per-Bot Limit: Approximately 30 messages per second across all chats combined.
- Per-Chat Limit: Strictly 1 message per second to any single chat ID.
- Group Burst Limit: Empirical data suggests around 20 messages per minute in group chats before triggers kick in.
If you exceed these, Telegram returns an HTTP 429 error. Unlike some platforms that just drop the packet, Telegram tells you exactly how long to wait via the retry_after field in the response. Ignoring this signal is the fastest way to get banned.
| Limit Type | Telegram Bot API | Microsoft Teams |
|---|---|---|
| Global Throughput | ~30 messages/sec | 50 requests/sec (per tenant) |
| Per Conversation | 1 message/sec | 7 ops/sec (send to conversation) |
| Error Code | HTTP 429 | HTTP 429 |
| Retry Strategy | Use retry_after field |
Exponential backoff + jitter |
Building Internal Safety Layers
Relying solely on Telegram’s external limits is risky. You should implement internal rate limiting that is stricter than the platform’s caps. Think of it as a buffer zone. If Telegram allows 30 messages per second globally, set your bot’s global cap to 10-15 messages per second. This absorbs traffic spikes and prevents accidental overshoots during high-load events.
Developers typically use token-bucket or leaky-bucket algorithms to manage this flow. These algorithms ensure that even if your queue backs up, you never burst beyond safe thresholds. For example, a safe configuration might allow only 0.5 messages per second per chat (one message every two seconds). This stays well below the 1 message per second hard limit, giving you room for error.
Handling the 429 Error Correctly
When your bot hits a limit, Telegram sends an HTTP 429 response with a retry_after value (e.g., 3 seconds). A common mistake is retrying immediately or using a fixed delay. Instead, adopt an exponential backoff strategy similar to what Microsoft recommends for Teams bots.
- Read the Signal: Extract the
retry_aftervalue from the error response. - Add Jitter: Add random noise (±20%) to the delay to prevent "thundering herds" where multiple retries happen simultaneously.
- Multiply on Failure: If the next attempt also fails, multiply the delay by 1.5x or 2x, up to a maximum cap (e.g., 20 seconds).
This approach ensures your bot gracefully degrades under pressure rather than crashing or getting banned for aggressive retries.
Anti-Spam Logic: Beyond Just Blocking Links
Rate limits protect your bot from being shut down. Anti-spam logic protects your community from abuse. Effective moderation bots combine static rules with behavioral heuristics. Simply blocking keywords like "crypto" or "bitcoin" is outdated and leads to false positives. Modern bots analyze behavior patterns.
Consider the "User Report Trap." Even a single spam report from a new contact can trigger restrictions for a newly created account. Older, established accounts tolerate higher report rates. Therefore, your bot should treat new accounts differently. A common practice is to require CAPTCHA verification for accounts younger than 24 hours or those with fewer than 10 prior messages in the group.
Behavioral Thresholds That Work
Instead of rigid blocks, use tiered enforcement based on frequency and content similarity:
- Flooding Detection: Flag users who send more than 3 identical or near-identical messages within 60 seconds.
- Link Spam: Monitor for users posting more than 10 messages containing external URLs in a 10-minute window.
- Burst Detection: Treat 5+ spam classifications within 1 hour as a trigger for automated enforcement, such as a shadow ban or temporary mute.
These thresholds mirror industry standards used by platforms like GetStream and have proven effective in Telegram groups. The key is configurability. Admins should be able to adjust sensitivity based on their group’s culture. A gaming clan might tolerate rapid-fire messages, while a professional network needs stricter controls.
Avoiding Common Pitfalls
Many developers fall into traps that lead to bans or poor user experience. Here are the most frequent mistakes:
Ignoring Account Age: New accounts are under higher scrutiny. Sending 50 cold DMs in 30 minutes with a brand-new account will result in a near-100% restriction rate. Spread messages over 8-12 hours and personalize them. For bots, avoid mass-adding users to groups without consent; this is a primary trigger for spam flags.
Over-Automation: Don’t let your bot delete messages or ban users without logging the action. Implement a "dry-run" mode during testing to see what would be deleted without actually doing it. This prevents accidental mass deletions due to database mismatches or overly broad regex patterns.
False Positives: Aggressive rules can ban legitimate users. For instance, a developer pasting a code snippet three times for debugging might trigger an "identical message" rule. Whitelist trusted users or admins, and create exceptions for specific channels or roles.
Tools and Libraries for Safe Implementation
You don’t need to build everything from scratch. Several libraries handle low-level HTTP and rate limiting for you:
- python-telegram-bot: A popular Python library that abstracts away complex HTTP handling and provides job queues for managing background tasks safely.
- grammy: A TypeScript library for Node.js that offers robust middleware support, making it easy to insert rate-limiting checks at various stages of request processing.
- telegraf.js: Another Node.js option known for its simplicity and flexibility, allowing custom plugins for spam detection and moderation.
Using these SDKs reduces development time significantly. An experienced backend developer can build a basic rules-based moderation bot in 10-20 hours. However, hardening it-adding logging, admin panels, and secure deployment-takes longer. Always store your bot token in environment variables, never in code repositories.
Future-Proofing Your Bot
Telegram continues to evolve its anti-spam defenses. As of 2026, heuristics are becoming stricter, especially for coordinated multi-account spam. Expect tighter enforcement on bulk cold outreach and link-heavy posts. To stay ahead:
- Monitor Metrics: Track your bot’s error rates and response times. Sudden spikes in 429 errors indicate you’re hitting limits.
- Update Regularly: Keep your SDKs updated to benefit from security patches and new features.
- Engage Users: Provide clear feedback when actions are taken. Let users know why they were muted or warned. Transparency builds trust and reduces reports.
By respecting rate limits, implementing nuanced anti-spam logic, and choosing the right tools, you can build a Telegram bot that is both powerful and safe. Remember, the goal isn’t just to automate-it’s to enhance the community experience without disrupting it.
What happens if my Telegram bot exceeds the rate limit?
If your bot exceeds the rate limit, Telegram returns an HTTP 429 "Too Many Requests" error. The response includes a `retry_after` field indicating how many seconds you must wait before sending another request. Ignoring this signal can lead to temporary throttling or permanent bans.
How many messages can a Telegram bot send per second?
Officially, Telegram states a global limit of approximately 30 messages per second for all chats combined. Additionally, there is a strict limit of 1 message per second per individual chat. Exceeding these limits triggers 429 errors.
What is the best way to handle HTTP 429 errors in a Telegram bot?
The best practice is to read the `retry_after` value from the error response and wait at least that long before retrying. Implement exponential backoff with jitter to avoid thundering herds. If the error persists, increase the delay multiplicatively up to a maximum cap.
How do I prevent my Telegram bot from being flagged as spam?
Avoid sending identical messages to multiple recipients, do not add users to groups without consent, and spread out message sending over time. Use personalized content and respect user preferences. For moderation bots, implement configurable sensitivity levels to minimize false positives.
Are there different rate limits for user accounts versus bots?
Yes. User accounts have much stricter limits, especially for direct messages. Unofficial estimates suggest a maximum of 50 DMs per day for user accounts, with heavy penalties for bulk messaging. Bots have higher throughput limits but are subject to strict per-chat and global caps.
Which libraries are best for building safe Telegram bots?
Popular choices include `python-telegram-bot` for Python, and `grammy` or `telegraf.js` for Node.js/TypeScript. These libraries provide built-in handlers for errors and queues that help manage rate limits effectively.
What is a "thundering herd" in the context of rate limiting?
A thundering herd occurs when multiple processes or requests retry simultaneously after a failure, overwhelming the server again. Adding random jitter to retry delays helps distribute requests evenly and prevents this issue.
Can I customize anti-spam rules for my Telegram group?
Yes, most modern moderation bots allow admins to configure sensitivity thresholds. You can set limits for message frequency, keyword filtering, and link detection. Customizing these rules helps balance security with user experience.