Checking channel/group subscriptions on Telegram

Checking channel/group subscriptions works only on Telegram.

To check if a user is subscribed to a group/channel, you can query the Telegram API using the getChatMember method.

To do this make screens in the builder:

1. Make a screen that has Request component where request method is set to POST.

2. Fill request URL:

https://api.telegram.org/bot<TOKEN>/getChatMember

Where <token> is your Telegram bot token. </token>

3. Add request body:

{
"chat_id": "<Channel_ID>",
"user_id": "{{this_user.platform_id}}"
}

Where:

  • channel_id is channel/group ID subscription of which you wish to check. To get the channel ID in Telegram, you need to open the channel in the web version. There will be a number at the end of the address bar - this is a channel id. At the beginning of this number add: -100, i.e. if the address bar of the web version displays
    web.telegram.org/a/#-2234567899
    	
    then in the Telegram ID field you need to enter: -1002234567899.
  • user_id is ID of the user who we check for subscription. If left unchanged, the check will be done for a user who hit Request component in the bot.

4. Add the bot from which the request will be sent by an fully authorised administrator to the group/channel which subscription will be checked.

5. Add a screen with a Fork. Set up transition from Request to Fork if the request is successful.

6. last_request.result.status will be checked, that is the Fork will get value of this variable.

7. Set Fork Target to take user to other screens depending on whether they are subscribed.

Server response to a query can set last_request.result.status to any of the following:

  • member – user is a subscribed,
  • left – user is unsubscribed,
  • kicked – user was kicked,
  • administrator – user is an administrator,
  • creator – user is a channel/group creator.

Set up Fork Target for each response, so that user is taken to the relevant screen depending on the server response.

8. Make screens with reports to the user.

To the beginning ↑