It’s time to make normal telegram bots #1

Do you create bots on Telegram? Even if not, it will be useful to know about some points regarding the development of telegram bots. There will be no code, only pictures and descriptions of 5 common mistakes that annoy me, an inveterate pedant in the field of developing simple interfaces.

1. Buttons that are attached to messages and buttons that are attached to the keyboard must perform the functions for which they are intended (behind the scenes)

Some kind of bot

Some kind of bot

The essence of the buttons that are attached to the keyboard (as in the screenshot) is quick input. Instead of forcing the user to enter a certain phrase or word, you can make a special button right in the place where the keyboard is located. Due to the fact that in many bots the user’s input is checked against the exact match of the message sent by him, such buttons greatly simplify interaction with the bot, organizing an effective dialogue that can be re-read. If the resulting dialogue does not make sense, then the buttons are used incorrectly – as in the bot in the screenshot: in it these buttons are used to organize navigation around the bot. One part of these buttons can be replaced with commands, the other part with buttons attached to a message. For example, as organized in the official bot:

Official bot

Official bot

2. Buttons attached to a message clog up the chat no less than the buttons built into the keyboard from the previous paragraph

Some kind of bot

Some kind of bot

These buttons are needed just for visual interaction with the bot. Their essence is to provide the ability to interact with the bot as an application. When you press a button, you expect that the text in the message will be updated, the menu will be rebuilt, and everything will be fine, but suddenly it hurts from the cognitive dissonance that arises after the appearance of a new message with new buttons instead of updating the previous one. Sometimes the buttons of the previous message are deleted and new ones are sent, but the previous message hangs half broken with a colon at the end and without a continuation in the form of a keyboard. Deleting the previous message is also not an option. The message and keyboard need to be updated, and nothing else.

Hidden text

The only case when a message cannot be updated in this way is when, after clicking a button, you need to send a picture and vice versa. In this case, you will have to delete the message.

3. Clicking on the buttons attached to the message cannot be left unanswered

The documentation says this:

NOTE: After the user presses a callback button, Telegram clients will display a progress bar until you call answerCallbackQuery. It is, therefore, necessary to react by calling answerCallbackQuery even if no notification to the user is needed (eg, without specifying any of the optional parameters).

Some kind of bot

Some kind of bot

The indicator waiting for a response from the bot to click will hang for 30 seconds. In some cases, telegram servers resend the request if there is no response. This is probably the most common problem that is very noticeable. This is clearly stated in the documentation, but for some reason the developers diligently continue to ignore this note and annoy users with waiting indicators.

4. Messages that involve waiting should not remain visible after the result is sent to the user

Messages are easy to update. As far as I know, a message for editing and deleting is available for 48 hours (for bots), which means that if the answer clearly requires a long wait, it is better not to leave a message that in all its appearance indicates that it will be updated upon receipt of the answer. First, if it updates, the user will not receive a notification. Secondly, if the update and deletion period expires, the message will remain hanging in the chat and nothing can be done with it. Therefore, you should not send messages that you plan to update after a long time. But if the period is expected to be short, then the message must, of course, be updated, and not sent the next one, as in the screenshot above. Or (for the sake of notifications, of course) write a text that does not imply that it will be changed (“At the end of processing, we will send the result in a response message,” or something like that).

5. Don’t captivate users, don’t become spammers

Previously, I made a separate command in my bots so that users could delete their data from the database in order to avoid possible mass mailings to active users. True, the command was rarely used, and it was easier to track users who blocked the bot. Therefore, respect your users and do not do suspicious actions for Telegram, such as mass mailings. Those who have blocked the bot should be marked as unavailable in the database. If you want to send a newsletter, send messages not to all users, but only to those active in the last n hours or days (if there are not many of them). You can send a maximum of 30 messages per second (I can’t say for sure about channels, I only make conversational bots, but there are much fewer there). If you exceed the limit, the bot will stop receiving requests and will be put on the stop list for a while. The limit can be increased through technical support if necessary (or your server can be raised).

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *