Recently, with the help of a bundle of an automated service and a Telegram bot, I set up automatic publication of a post about the start of a stream on Twitch in my Telegram channel. And in this article I will tell you in detail how this is done.
The automator connects different applications and web services to each other, monitors events in them and allows you to create chains of actions according to the principle: “if this happens, then..”.
For example, you publish a post on a social network, this serves as a trigger for the next event – a link to the post is sent to the messenger chat.
The variability and possibilities are simply huge: with proper imagination and understanding of the tasks set, you can significantly make your life easier by automating processes. But it is important to understand that Automators do not support all services (mostly only Western and the most popular ones), and the list of possible actions within them is limited (for example, one social network only allows you to read its feed of posts for the presence of new ones, but does not allow you to publish anything). However, if you are able to use the API and Webhooks, then this restriction can be circumvented (but this is inaccurate).
There are quite a lot of automators and most of them are focused on solving business problems, and therefore they have only paid versions and are not focused on social networks. Nevertheless, it is possible to distinguish two services that are the most user-friendly and with the availability of a free tariff plan: IFTTT and Make (aka Integromat).
Ultimately, I decided on Make, because IFTTT had a long delay between the start of the stream and the publication of the post in Telegram (about 20 to 40 minutes).
Creating a Telegram bot
First we need to create our own bot in Telegram and make it the administrator of our channel. This is done easily and quickly:
In the messenger search bar, enter the nickname BotFather and go to him in the chat. This is the official Telegram service for registering user bots. Be careful and don’t fall for fake accounts. The bot we need will have a verification icon and the address @BotFather.
We write a command to the chat to launch BotFather:
In the response message, you will receive an instruction with a list of all available commands.
We give the command to create a new bot:
The reply message will ask you to come up with a name for our bot.
You need to write the desired name for the bot to the chat, with the condition that there is a postscript “_bot” (or “_Bot”) at the end, for example Mikulski_bot. If the name is already occupied, then you will be asked to come up with another nickname.
After that, we will receive a message with an HTTP API token – we will need this code when setting up the automator.
It remains only to go to the control panel of your Telegram channel; in the search for the “Administrators” section, find your bot, add it and grant the necessary rights (in our case, you can remove all the checkboxes, except for the ability to publish messages):
Setting up Make
Register an account on https://www.make.com – click the Get Started Free button (there is a quick registration via Google account) and enter the requested data: Email, nickname, country and the hosting region (EU or US).
Then there will be another questionnaire with a choice of the answer option:
This ends the registration and we get to the control panel, where we click on the button “Create a new scenario”:
Click on the round plus button to add a trigger and select Twitch through the search bar:
In the drop-down list of functions, you need to select the “Watch Streams” trigger (it signals when the stream starts or ends):
A new menu will appear where you will be asked to enter a Webhook and Connection (linked Twitch account).
Since we haven’t created one yet, click Add and change the name in the Webhook name line (if desired), and in the Connection line we also click Add, change the name of the connection, click Save and log in via Twitch to link your account.
After creating a Web hack and Connecting, you will need to specify the User / Channel ID: roughly speaking, the channel you need to monitor. You need enter your Twitch-nickname and the search itself will determine the ID number of the channel.
In the context menu Event Type, you need to choose which event to follow:
When Specified Channel Starts a Stream;
When Specified Channel Stops a Stream.
In our case, we are interested, of course, in the first graph.
Click Save, then Ok and create the second module by clicking on the plus button next to the one just created.
By analogy with the previous actions, add a Telegram Bot and select the action “Send a Text Message or a Reply” (send a text message or reply). Create a connection with the “Add” button and insert the same code that BotFather provided to us into the Token string. Click “Save”.
- In the Char ID line, you need to enter the address of the Telegram channel where you want to publish alerts in the format @channel_name.
- In the Text line, we write the text of the message for the published post.
- Parse Mode is used to determine the layout of the message (Markdown or HTML). If you don’t understand what it is and how to use it, leave the field empty.
- The Disable Notifications checkbox can be used to disable the sound notification. That is, if you set the value “Yes”, then the subscribers of the channel will receive a notification, but without sound.
- With the Disable Link Previews checkbox, you can disable image previews for links in the text, which Telegram, by default, creates automatically.
It remains only to click on the floppy disk icon at the bottom of the screen to save the script, exit the editor mode and turn on the toggle switch at the top right to activate automation and it began to monitor events.
Just in case, while in editor mode, pay attention to the “Scheduling” section at the bottom left. By default, the Twitch trigger “Watch Streams” immediately sets the desired mode “Immediately as data arrives” (Triggered as soon as data arrives). But it is better to double-check yourself additionally, because there are other modes: on certain dates, once, every day and so on.