Skip to content

Anonymous chat in Telegram using a bot and Integromat

Сценарий с анонимным чатом Telegram через Integromat

Updated: 26.04.2021

In our kind of service, sometimes you have to let the client and the author talk to each other directly.

But it is necessary to be anonymous so that they cannot see each other and write to each other directly. At the same time, it should be possible for the agent to help them and intervene in negotiations if necessary. If you have a similar task, this scenario will work for you.

Creating groups in Telegram

  1. The first thing to do is to create 2 groups. In the first group will be the agent and the client. Group 2 will be for the agent and the author. In this case, the groups act as “rooms”, where new users come, get a service, and then get deleted. New users do not see the old messages (excepting their own, if they have been added twice or more).
  2. Add your bot in both chats (better to create a separate bot for this scenario), make him the administrator. The group will be converted to a supergroup.
  3. Find out the id of each group using @myidbot or other bots for this.
  4. Add description, logo, and other info to the groups.

Implementing the scenario in Integromat

Here is what this scenario would look like if there are 3 agents and they have 5 pairs of chats in total. All this is handled by 1 bot. The bot copies a message from 1 chat and sends it to 2 chat.

Сценарий с анонимным чатом Telegram через Integromat
An anonymous Telegram chat scenario via Integromat. Such dandelions

Let’s look at an example with 1 pair of chats.

Creating Telegram Watch Updates module

Go to Integromat, create a scenario. The first module Telegram -> Watch updates. Connect the bot there. Further, with any action in chats, where the bot is added, a notification will come here.

Further, if there are several agents and several chats, set filters, so that the bot posts in chats of the desired agent. If the agent is only one, then skip this point.

Посылаем бота в ту ветку, в которую надо на основе id чата уведомления
Send the bot to the branch you want, based on the chat id of the notification

Next, to cut off all unnecessary notifications, you need to put filters on the type of message. And specifically, I am interested in only 6 of them:

  1. Text
  2. Photos
  3. Documents
  4. Voice
  5. Video
  6. Audio

Creating network of routers

Make a router and put a verification for “not empty” messages with the types written above.

Роутер с проверкой на типы сообщения
Router with message type verification

Here are two screenshots with examples of text and photo filters.

Проверка присутствия текста сообщения
Checking the presence of message text

 

Проверка присутствия фото в сообщении
Checking the presence of a photo in the message

Let’s say we put filters on the type of message. Next, we need to put filters on the id of the chat.

  1. If the notification came to chat 1, then copy and send the message to chat 2
  2. If the notification came to chat 2, then copy and paste the message to chat 1

This is what the filter looks like:

Фильтр с проверкой чата
Filter with chat ID verification

And this is what the final text message module might look like after the filter:

Копирование и отправка анонимного сообщения
Copying and sending an anonymous message to another chat

For each type of message, you need to create different Telegram modules. For example, Send a Text Message, Send a Photo, Send a Document, etc.

Here, if a packet reached this module, it means the message was a text or photo or document message, it’s in the client’s chat, and it needs to be forwarded to the author’s chat.

Copying a message in the last module
Copying a message in the last module

The text of the message will be the text from the client chat message.

  • It is either the client’s message, then the Client: will be added before the message.
  • If the message is from an agent, then it will be preceded by Agent:
  • The same, only in reverse, is done in the branch where the chat id of the author.

It is also important to trim message with substring function so that if the message is too long, Telegram module won’t generate error and scenario will not stop.

For all other types of files (audio, video, document) you can simply add Caption of the client or author to make it clear “who” writes.


That’s all, this scheme works fine. The agent just observes the process, rather than passing every little thing manually from chat to chat. The delay between message transfers is 2-5 seconds, which does not affect the quality of communication at all. Well, thanks to Telegram for such features!

If something is not clear, ask in the comments. Happy automating!

Leave a Reply

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