Organization of communications in Telegram via proxybot

Hi all! In this article I will talk about the possibility of organizing communications in Telegram using the proxybot bot. It allows its owner to publish his bot on the Internet and receive all incoming messages and respond to them without revealing his personal Telegram account or creating additional accounts in the Telegram application. Bots can be easily registered via @BotFather, you can create as many of them as you need.

This bot reveals interesting possibilities in combination with the use of “supergroups” in which “topics” can be created. When the bot is configured to receive messages in a supergroup (how to do this will be below), it will create a topic in it with the client’s name as the topic name when the client first contacts. And subsequently the bot will send all messages from this client to the same topic. Thus, all communication with the client takes place in his personal “topic”. The topic can be deleted with the /del command.

The gif at the end shows what this communication looks like for the user Pasha Flores.

For teamwork, simply invite your colleagues or employees to the group and they can answer messages with you / instead of you!

How to create and configure a supergroup?

Instructions for launching the bot yourself are available on your home page. website project, there is also a short video on how you can create and launch your bot directly from your phone. Here I provide instructions for creating and setting up a supergroup.

To configure proxybot to receive messages to a supergroup, you need to perform the following steps:
1. Create a group
2. Add your bot to it
3. In the group settings, activate topics (and the group turns into a supergroup)
4. Make the bot an admin with the rights to create topics
5. Write the /setdefault command to the group to receive all new messages to it

Use without a group (feedback bot)

In principle, proxybot can be useful without using a supergroup. For example, in order to publish it to receive feedback (reviews/suggestions/complaints/…). The bot forwards all received messages to the bot owner and marks each last unanswered message from the client with the ⚡️ symbol. After replying to the message, the bot removes this emoji. This makes the task of finding an unanswered message in the history somewhat easier.

Here you can see how users Sasha Li and then Pasha Flores send messages to the proxybot. Each of them receives an answer in their turn. The last chat message is always sent to the last contact. And you can select a specific message and click “Reply”.

Technical details of the bot implementation

The bot's source code is written in python and posted in public access. The bot is designed to work as a Google Clound Function (other platforms are on the way..), or it can be run as a regular Flask application.

The bot uses a Mongo database to store its settings and tracking table. The tracking table works similarly to conntrack in Linux to implement SNAT & DNAT functionality. It stores user IDs and names and some other service information: u_id, u_chat, u_name, u_thread, u_last_id, p_chat, p_thread, timestamp.

When the bot receives messages, it looks for the sender in this table by u_id, then by u_chat. Yes, this even allows your clients to create their own group and add your bot there, and in the group communicate together, say, with your team! It turns out to be a kind of communication bridge between different teams. Only in order for your bot in someone else’s group to receive messages without assigning admin rights to it, it needs to set the Group Privacy = off setting, this is done through the same @BotFather .

Summary and feedback

Using the Proxybot bot allows you to conveniently and safely organize public communications in Telegram. Clients can contact us directly from their messengers, and we also do not leave the familiar and convenient Telegram application. Communication on different projects can be organized through different bots. Each bot is in a separate group, each group has its own team for working with messages. All supported message formats (audio, video and others) are sent in the same way as text messages.

If you find this project useful, please mark it with stars on Github. Feedback regarding this project is accepted (using the same bot) at @devproxybot

Similar Posts

Leave a Reply

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