Checking channel/group subscriptions on Telegram

Subscription checkworks only in Telegram.

You can check whether a user is subscribed to a group/channel using the Telegram API request with the method getChatMember.

To do this, set up the screens in the builder:

1. Create a screen with the Native request component or just Request. If you use a regular request, select the POST method and fill in the request URL:

https://api.telegram.org/botTOKEN/getChatMember

Where instead of TOKEN — your bot’s token in Telegram.

In the Native request you don’t need to add the token or select the method.

2. Add the request body:

{
  "chat_id": "Channel ID",
  "user_id": "{{this_user.platform_id}}"
}

Where:

Channel ID — the ID of the group/channel to check the subscription for. (To get the channel ID in Telegram, open the channel in the web version. At the end of the address bar there will be a number — this is the channel ID. Add -100 at the beginning of this number. For example, if the web version shows web.telegram.org/a/#-2234567899, then you should enter -1002234567899 in the Telegram ID field. The group ID can also be found in the Users section after adding the bot as a group admin).

Instead of a channel ID, you can also insert a channel link in the format @botmothercom. This link is available in the channel settings.

user_id — the ID of the user whose subscription we want to check. You can leave it unchanged, then the subscription check will be performed for the user who reached the Request component in the bot.

3. Add the bot (the one sending the request) as an administrator with full rights to the group/channel. This is the channel where we will check the subscription.

4. Add a screen with a Fork. Set the transition to the Fork from the Native request in case of a successful request.

5. In the field “What is checked by the Fork” select the variable. The variable name for verification is:

last_native_request.result.status

This means that the Fork will take the value from this variable if you use a Native request. If you use a regular request, the Fork will take the value from:

last_request.result.status

6. Set up the Fork goal conditions to route the user to different screens depending on whether they are subscribed or not.

In the server response, the variable last_native_request.result.status and last_request.result.status can have the following values:

  • member — the user is a subscriber
  • left — the user is not subscribed
  • kicked — the user was removed
  • administrator — admin
  • creator — creator

To make the user go to the corresponding screen depending on the server response, configure the Fork goal conditions for each response using regular expressions.

For this, change the Expected data type in each Goal Fork to Regular expression, and in the expected variable value add the regex for subscribed users, creator, and admin:

(member|creator|administrator)

For all others — unsubscribed or removed from the channel — the regex will be:

(left|kicked)

7. Set up the screens for the user’s reply.

How to grant access to a channel/group after payment in the bot can be found here →

Payment on a third-party site can be set up with an External event.

To the beginning ↑