Using Telegram Bot with Make

Telegram is one of the most popular apps Make customers use. This tutorial guides you through the steps to set up Telegram to work with Make.

You can use Telegram in your Make scenarios to achieve the following basic use cases:

  • trigger a scenario with a Telegram message and send the message data to another app

  • get data from other apps and post a message to a Telegram channel or group

To use a Telegram bot in Make scenarios, you will need to:

  1. Create a Telegram bot and store its API token

  2. Add the bot into a chat as an admin

  3. Find the Chat ID for the channel or group

  4. Create the Make scenario using an API token and Chat ID

Watch the video

Get the Telegram desktop app

This tutorial explains the process using the Telegram desktop app, which makes the configuration easier. Download the Telegram desktop app. You can also use the mobile app.

Create a Telegram bot

You will interact with Telegram groups or channels using a Telegram bot. You need to create the bot and get its API token, which you will then use when connecting Telegram to Make.

  1. Use the search box in Telegram to find the user BotFather. The user’s handle is @BotFather. Watch out – the other users or groups with the same name are spam bots.

  2. Click Start.

  3. In the message you receive, click /newbot or type /newbot into a message.

  4. Type a name for the bot and send the message.

  5. Type a unique username for the bot and send the message.

  6. In the message from BotFather, find the token to access the HTTP API. Copy and store the token somewhere, e.g., in a text file.

Note: To post in a channel or group, your bot must be an administrator of the channel or group. In the Manage channel or Manage group dialog, click Administrators and add your new bot with all permissions.

Add your bot to the channel or group

Your bot must be an administrator of the channel or group if you want the bot to read and post messages on your behalf. The same instructions apply to both setting up channels and setting up groups.

  1. Open the channel or group where you want to add the bot.

  2. Click the three dots in the top-right corner of the channel or group, and then click Manage channel or Manage group.

    telegram_manage_channel.png
  3. In the dialog that appears, click Administrators, and then click Add administrator.

  4. Search for your bot using its name or its handle.

    telegram_add_administrator.png
  5. In the search results, click the bot, and then click OK.

  6. Optionally, set up the bot’s permissions. We recommend you leave the permissions at their defaults. When done with setting up permissions, click Save.

    telegram_administrator_permissions.png

Your bot is now a member and an administrator of the channel or group. This allows the bot to read and post messages on your behalf.

Find the Chat ID

To post messages into Telegram channels or groups, you need to know the Chat ID. You will use the Chat ID when setting up Make to read and send messages.

Find the Chat ID for Public channels

  1. Click the three dots menu in your channel and select View channel info.

  2. Find the link to the channel beginning with t.me/ 

The text that comes after t.me/ is your Chat ID. Example: if the link is t.me/exampleChat, the Chat ID is exampleChat.

Find the Chat ID for Private channels and Groups

Private channels and Groups don’t have a link from which you could easily find the Chat ID. This is why you need to find the Chat ID by sending a Telegram message to a Make scenario.

  1. In Make, create a new scenario.

  2. Add the Telegram Bot > Watch Updates module.

  3. Under Webhook, click Add. Type a name for the webhook.

  4. In the Create a webhook dialog, under Connection, click Add.

  5. Type a name for the connection, and then paste the API key that you received from BotFather. Save the connection settings and the webhook settings.

  6. Right-click the Watch Updates module, and then click Run this module only.

    • Make starts listening for a new message.

  7. In Telegram, send a message to the channel or group whose ID you want to find. Your bot must be an administrator of this channel or group.

    • Make receives the message through the webhook you set up. A number appears next to the module. Clicking this number allows you to inspect the details of the message.

    telegram_module_results.png
  8. Click the number next to the Watch Updates module. Find the Chat ID under Message > Chat > ID. Save the ID for later use, including the minus sign at the beginning.

    telegram_find_chat_ID.png

Use case 1: Send new RSS feed items as Telegram messages

RSS feeds are files that contain a summary of updates from a blog, a news site, or any other website that chooses to publish an RSS feed. In this use case, you will create a scenario, which will get updates from an RSS feed and send them as Telegram messages.

Step 1: Add a trigger module: Watch RSS feed items

A trigger module launches a scenario whenever something happens. In this use case, the trigger will watch for updates to an RSS feed. When a new item appears on that feed, the scenario will run and send that item to your Telegram chat.

  1. Create a new Make scenario.

  2. Click the plus sign to add the first module. From the list of apps, select RSS, and then select Watch RSS feed items. Read more about what you can do with RSS.

  3. In the module settings, paste the URL address of your favorite feed. Leave the other settings as they are for now.

    • If you don’t have a favorite feed, try this out: https://www.nasa.gov/rss/dyn/breaking_news.rss

  4. Click OK

  5. In the Choose where to start dialog, select one of the following options:

    • From now on: Make will process only those items that will be added to the feed from now on. Select this option if you don’t want Make to send Telegram messages for the items that were in the feed before you created the scenario.

    • RSS feed items from after a specific date: Make will start retrieving and processing items published after the date you selected.

    • All RSS feed items: Make will retrieve and process all items that are available in the RSS feed.

    • Select the first RSS feed item: shows the latest items and lets you choose one of them as the starting point. Make will retrieve and process the selected item and all newer items.

    To be able to test the scenario, we recommend you select a specific item. This way you ensure that there are some items to process when testing the scenario. If you selected From now on, Make would not retrieve older items and you would have to wait for the RSS feed owner to publish new items.

  6. Click OK to save the settings.

  7. Right-click the module, and then click Run this module only.

    • This retrieves one item from the RSS feed. You can click the number next to the module to view what the results look like. Running a module once also helps Make identify what types of data to expect from that particular module, which in turn helps you work with that data in subsequent modules more easily.

Step 2: Add an action module: Send a text message or a reply

Now that you have a module that reads data, you will add another module, which will send the data to Telegram.

  1. Click Add another module, then find the Telegram Bot app. Click that app, and then click Send a Text Message or a Reply.

    telegram_send_message_module.png
  2. Create a new connection or use the connection that you created when following instructions in Find the Chat ID for Private channels and Groups

  3. Enter the Chat ID of the chat where you want to post. Follow the instructions in Find the Chat ID.

  4. Use the Text field to construct your message. You can type text, as well as map fields from the RSS module.Mapping

    • When you place the cursor into the Text field, Make offers a dialog where you can insert data retrieved by the RSS module into the Telegram module. This is a key concept in Make called mapping, which allows passing data from one app to another.

    • Mapped items appear in the color of the module where they originate and are marked with the number of the module.

    • See the following screenshot for an example of how to construct a message using typed text, Markdown formatting, and mapped items from the RSS module.

    telegram_send_message_configuration.png
  5. In Parse mode, select Markdown

  6. Click OK.

Step 3: Test and activate the scenario

To test the scenario, click Run once. The scenario retrieves another item from the RSS feed (if there are any) and sends it to your Telegram chat. Then, you click the numbers above the modules to inspect what data the scenario retrieved and how the data was processed.

Before you activate the scenario, click the clock icon on the RSS module. In the Schedule setting dialog that appears, tell the RSS module when to check for new items in the RSS feed. If there are items to process at the scheduled time, the scenario will run and process the items.

rss_schedule_setting.png

Finally, click the ON/OFF button in the bottom left corner to activate the scenario. From now on, the scenario will automatically check for new items in the RSS feed based on the schedule you set up.

Use Case 2: Send Telegram messages to a Discord server

Discord and Telegram are the two most used tools among online communities. Many people use Make to send Telegram messages to Discord or the other way around.

Similarly to the RSS feed use case, you will add a trigger module, which will watch for new messages in your Telegram chat. Then, you will add an action module that will resend the Telegram message to Discord.

To build this automation, you need the following

  • a Telegram bot

  • a Telegram chat where the bot is an admin

  • a Discord server

  • a Discord channel to which you want to send the messages. 

  1. Create a new scenario.

  2. Add the module Telegram Bot > Watch Updates. Configure the module the same way you did in Find the Chat ID.

  3. Click Add a new module. find Discord, and then select the Post a Message module.

  4. Under Connection, click Add.

  5. In the dialog that appears, log in to your Discord account, and then select your server and the channel to which you want to post messages. Click Continue.

  6. Leave the permission settings at their defaults and click Authorize.

  7. Test the scenario by clicking on ‘Run Once’ and send a message to the related Telegram chat. If the message was sent to Discord without any problems, you can activate the scenario by turning the switch on the left bottom corner on. 

Use Case 3: Send new form submissions to Telegram

In this use case, you will create a scenario, which sends the summary of a user-submitted form to a Telegram chat. You can use this automation to send notifications for your new leads. In this example, use the popular Google Forms.

To work with your form responses, create a spreadsheet that will store the form submissions.

  1. Open your Google form.

  2. Select the Responses tab

  3. Click Create Spreadsheet.

The spreadsheet is created from the form and you can now proceed to work with your form responses in Make.

Add the Google Forms > Watch Responses trigger module

  1. Create a new scenario and add the Google Forms > Watch Responses module.

  2. Under Connection, click Add, and then follow the instructions on-screen. Alternatively, use an existing connection.

  3. Choose the spreadsheet that you created to store the responses. Select the sheet that contains the responses. Set the Limit to 1.

    • The Limit setting of 1 tells Make to process one form response at a time.

    google_forms_settings.png
  4. Click OK.

  5. Choose where to start getting data. If this is a new form, you can select All. Then click OK.

Add the Telegram Bot > Send a text message or a reply module

  1. Click Add another module, and then select Telegram Bot > Send a text message or a reply.

  2. Under Connection, use the same connection you created earlier.

  3. Enter the Chat ID.

  4. Create the message. Use mapping to insert the data from the Google form.

    telegram_send_message_configuration_2.png
  5. Click OK.

  6. To test the scenario, send a new submission to your form. Then click Run Once.

After running the scenario, you receive the Telegram message as configured. If you don’t receive a message, make sure that there are new form submissions to process in your Google form.

When you’re satisfied with the test, you can set up a schedule and activate the scenario.