What considered telegram bot rate limit?

135 views Asked by At

From telegram api here

If you're sending bulk notifications to multiple users, the API will not allow more than 30 messages per second or so. Consider spreading out notifications over large intervals of 8—12 hours for best results.

But if my bot has many users let's say that 1000 users at the same time send me a message and I will reply to them at the same time. Will it be considered broadcasting? Will I hit the rate limit? If not, how does Telegram understand that I reply to the user's interaction and not broadcast? I use grammyY library's reply but under the hood, it uses sendMessage api call. How will it understand that it's reply?

And btw, I'm using this pattern to work with grammy.js:

app.post(`/bot/${myBot.bot.token}`, async (req, res, next) => {
 myBot.bot.handleUpdate(req.body).catch((err: BotError) => {
  if (isBotFlowError(err.error)) {
   if (err.error.sendErrorMessageToUser) {
    const message = err.error.message;
    err.ctx.answerCallbackQuery(message);
   } else {
    logger.error(err);
   }
  }
 });

 res.sendStatus(200); // answer OK HTTP
});

I immediately return response and then process incoming message.

1

There are 1 answers

0
Roman On

From my understanding, bulk notifications mean sending the same message (update) to multiple users. In any case, your system should be able to handle the rate limits both in a preventive way (rate limiting aka throttling on the client side) as well as reactive (retrying 429 errors after a delay). In the Java ecosystem the resilience4j can be used. For python hyx is a similar library, and for NodeJS I heard about mollitia, but never used it. Hope that it helps.