简体   繁体   中英

Error 400 bad request while sending message with Telegram Bot

I have a Telegram Bot for a company employees which allows admin send messages to all employees (more than 10k users). List of all employees chat_id are stored in database and by using a specific command admin can send a message to all users.

The problem is when the admin send a message to all employees it will be sent to some users (very first users in the loop on all users) but it will face error 400 (Bad request) for other users (errors are being logged in file).

I'm using C# Webrequest object and I divide user list to pages of 100 user. After sending message to 100 user it goes to next 100 users.

Can anyone help me with this ? In general, is this a good way to send bulk messages with telegram bot ?

I got the same problem like you. I've broadcasted a single message and after 2-3 thousand users my server reported 400 (Bad request) Errors. BUT this didn't affect the delivery of the message. The messages seemed to arrive properly (i could only ask some recipients but they all got the message).

Telegram doesn't really state hard limits but thats the official guideline: https://core.telegram.org/bots/faq#broadcasting-to-users

Telegram there states that, if you reach the limit of messages/time, you get a 429 Error.

In general, i just got a extra thread that sends 50 messages and then waits 5 seconds which is probably a bit overcautious.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM