Bot in Telegram groups
- Add a bot to a group →
- Manage bot rights in a group →
- Group Support in Botmother →
- Work with groups via the builder →
- API requests for 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.
To make the bot work in a group, just add it to this group. You can do it like this:
- Open group or bot settings.
- Click the "Add" button.
- Find the desired bot or group in the search.
- Make the bot an administrator with the necessary rights.
- Enable group support in Botmother settings.
You can manage bot abilities via BotFather.
- Send /mybots command to BotFather.
- 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.
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.
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).
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.
When a user submits an application to join a closed group, the bot will be able to automatically accept or reject this application.
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.