Bot work in Telegram groups

You can test the bot in a group without restrictions if you are on a paid plan, since it is impossible to assign a group as a tester.

Add a bot to a group

To make the bot work in a group, just add it to this group. You can do it like this:

  1. Open group or bot settings.
  2. Click the "Add" button.
  3. Find the desired bot or group in the search.
  4. Make the bot an administrator with the necessary rights.
  5. Enable group support in Botmother settings.

Manage bot rights in a group

You can manage bot abilities via BotFather.

  1. Send /mybots command to BotFather.
  2. Select the desired bot and click Bot Setting.

In Bot Setting there are the following settings for the group:

Allow Groups — allow adding the bot to groups.

If you turn off the group by clicking Turn group off after switching to Allow Groups, you will not be able to add the bot to groups. If the bot has already been added to some groups, it will remain in them and, despite the restriction, will be able to process requests.

Group Privacy is responsible for the bot access to all group messages.

If you click on the Group Privacy button and then turn off Privacy mode, the bot will be able to receive all messages from the group.

In Group Admin Rights and Channel Admin Rights you can manage bot rights in groups and channels.

By ticking the rights buttons, you can enable the bot to change the name and avatar of the group/channel, block and unblock participants, pin, delete messages, invite new users, assign administrators, etc.

Group support in Botmother

In order for the bot created in Botmother to work with groups, enable group support in Settings.

After you add the bot to the group via BotFather and add settings for working with groups in the builder, you can write to the bot from the group. To do this, any user of the group can write /start in the group. After that, a message chain from the bot will start and the ID and name of the group will appear in Users.

The group is displayed as a single user, the group ID always starts with a minus sign.

Messages from the bot will be visible to all members of the group.

If Template Event is configured in the bot, it will also work in the group if the bot is added to the group.

You can send instant and trigger broadcasts to the group.

The bot does not divide group members among themselves, perceiving the group as one user, that means that in Dialogues separation by users within the group won’t be seen (that is, the group will be a single user).

Work with groups via the builder

The following functions are available in Botmother to work with groups:

1. New message in a group (Telegram) sends one specific message or screen in response to everything that users write to the bot. The event can be configured for messages from all or from specific users.

2. A ban on working with all groups except a specific one.

Sometimes you need to give permission for the bot to work with one specific group in advance, while prohibiting the bot from working in other groups.

If you prohibit from working with groups through Botfather, it will prohibit working with all groups, and Botmother cannot do such prohibitions at all. But the bot can check which group the user came from and transfer to the bot scenario only those users who switched from the allowed group.

To implement, create a Message in a group (Telegram) event.

The Message in a group (Telegram) event is necessary for the check to be carried out only in groups. If you do a check without this event, users who write not from the group but personally to the bot will not be able to communicate with the bot - they will fail the check, since their ID does not match the group ID.

Add Fork as the first component on the screen that will come when the event is triggered.

The name of the variable from where the fork will take the value should be lastUpdate.update.chat.id

This variable contains the group ID.

In Fork, add one goal, the ID of the allowed group should be in its value.

The transition to Goal 1 will lead to the main scenario.

By default, the transition will lead to an empty screen or to a screen with a warning that the bot does not work with this group.

Despite the fact that the bot will be added to all groups, the message from the default transition screen will be the only message of the bot in the prohibited groups, and the usual bot scenario will be displayed for the allowed group.

3. Chat request (Telegram).

When a user submits an application to join a closed group, the bot will be able to automatically accept or reject this application.

4. You can forward messages from bot users to the group using Request or Native Request.

5. Alert and Message by recipient ID will help you send a message to a specific user in Telegram. This user can also be a group.

API requests for groups

Requests are used in the cases Forward messages from a group/channel to a bot and Check a subscription to a channel/group in Telegram.

There are many other methods of the bot for working with groups in Telegram API documentation.

They can be implemented using Native Request or Request.

To the beginning ↑