Responsible Use
Telegram bots are an official, supported way to automate conversations, and Telegram actively limits and bans bots that spam. Following these rules keeps your bot online and your users happy. This project is not affiliated with Telegram.
Messaging rules
Section titled “Messaging rules”- Only message users who started your bot. A bot cannot start a conversation with someone who never wrote to it, and it should not try to work around that.
- Honor opt-outs. Support a
/stopcommand (or similar), remember who used it, and never message them again unless they come back. - Handle blocks. When sending fails with error
403, the user blocked the bot. Stop messaging them. - Respect the limits. Use a
RateLimiterfor broadcasts and do not work around HTTP 429 responses. The client already waits for theretry_afterTelegram asks for. - Be clear about what the bot does. Describe it in @BotFather and in
/start, and tell users when a human is or is not reading.
Protect secrets
Section titled “Protect secrets”- Keep the bot token in an environment variable or a secret manager. Revoke it with
/revokein @BotFather if it leaks. - Use a webhook secret so only Telegram can call your endpoint.
- Escape untrusted text with
Format::html()orFormat::markdownV2()before using it in formatted messages.
Protect personal data
Section titled “Protect personal data”Messages, user IDs, names, and files are personal data under laws such as the GDPR and Brazil’s LGPD. Keep sessions small, set TTLs on session stores, store only what you need, and give users a way to delete their data.
Group etiquette
Section titled “Group etiquette”In groups, reply to commands addressed to your bot and avoid reacting to every message. Commands such as /start@other_bot are ignored automatically when the mention names a different bot.