Use IFTTT to create an automated broadcasting bot for a channel

Step 1: Gathering our ingredients

Creating a channel:For your automated Telegram channel you will first need a channel to maintain (if you don’t have one already). To create a channel use your Telegram app of choice and press the “pen and paper” button which you would also use to create new group or swipe the chat list to right on Android.From there tap “New Channel” and set a name, description and picture for it. The most important part is to make sure the channel type is set to public, so that your channel has a username your bot can send messages to.

Creating a bot:Next we will create a bot using @BotFather which we will link to IFTTT. If you’ve never done this before just send /newbot to @BotFather on Telegram and he will guide you to the process. The username or the description is not very important, because the users of your channel will never see it anyway. Just make sure you keep the message containing the token.

Signing up for IFTTT:Signing up for IFTTT is easy. Visit https://ifttt.com/join and enter your email address and a password. It then should log you in immediately and start a little introduction tour. After finishing, it should you show a similar page to this:

Step 2: Adding the bot to our channel

To allow the bot to send messages to our channel we will need to add it as an administrator.To do that just open up the channel info of the channel we just created in your Telegram client and press AdministratorsAdd Administrator. In the search enter the username of your bot and add it by pressing it as soon as it shows up in the search.

Step 3: Connect your bot to IFTTT

Now let’s go back to the IFTTT website. To create a new recipe click on your username in the top right and then choose Create from the dropdown menu. After clicking on the big this IFTTT will give you a huge selection of what they call trigger channels to choose from. Essentially those IFTTT channels get triggered when a specified event happens (e.g. each day at 4 am or whenever you receive a new tweet). You can play around with all of them and most of the channels should work with your Telegram bot, but to keep this tutorial at a reasonable length I will demonstrate adding an RSS feed to our channel, so that the bot forwards the latest updates.

The trigger channel for this is called Feed and after selecting it IFTTT presents you with two buttons. We want to forward every new item in the RSS feed to our Telegram channel so we will choose New feed item for this tutorial.Next you will need to enter a RSS feed the trigger will use as a source.

After entering an RSS feed of your choice press Create Trigger and that so we can choose a channel the event will get forwarded to. For our Telegram bot we will need to choose the Maker channel. Connect the channel and then click on the Make a web request button.

The last thing we need to do is to fill all the fields with stuff and then we’re good to go! Let’s start:

In the URL field you need to put the url IFTTT needs to call to send a message to your bot. This would behttps://api.telegram.org/bot<token>/sendMessagewhere you replace <token> with the token you got from BotFather in step 1.

Method needs to set to POST and Content Type to application/x-www-form-urlencoded.

The last thing to do now is to fill the Body of the request.The first part should be chat_id=@<channelusername>&text=. Here again you need to replace <channelusername> with the username of the channel we set up in step 1.The second part you will need to fill with ingredients from the bottle at the right of the field. You can choose anything from the bottle really and can even input your own text after the first chat_id=@<channelusername>&text= part.

In the end your request should look more or less like this:

Now click Create Action and we’re done! That’s it. Now IFTTT should send a request to your bot whenever a new item appears in the RSS feed.

For more info on what you can put in a request have a look at the documents for the Bot API. (For example you can use Markdown to format your channel’s messages so that they look nicer!)

Leave a Reply

Your email address will not be published. Required fields are marked *