We create a bot in Telegram without programming. Step by Step Instructions (Part 2)
The second part of the publication about creating your own Telegram bot ...
Navigation:
Step 1. We will use the existing bot. (available in the first part of the article)
Step 2. Create a bot using the command. (available in the first part of the article)
Step 3. Configure the created bot. (available in the first part of the article)
Step 4. We instruct the bot to administer the channel. (available in the first part of the article)
Step 5. We train the bot to complete the task
Step 5. We train the bot to complete the task
And the service https://ifttt.com/ will help us with this. First you need to register. Right on the main page of the site. We do it!
Or we go through authorization through Facebook or Google.
After entering the email address, set a password and click on the “Singup” button.
In the item "My applications" there is an item "My applet". Open and click on "NewApplet". Here is what we see.
The highlighted blue word “this” is the button we need. By clicking on it, you will see what is shown in the screenshot. All these are services to which you can connect the bot.
Let’s take for example ordinary news from RSS feeds. Ask in the search for reliable information. We see this.
Now click on the search result. And before us appear two functions. We must choose the one on the left - “New feed”.
This window prompts you to specify the address of the RSS feed.
Https://www.sport.ru/rssfeeds/formula1.rss. Click on the button. Everything worked out?
Now this news feed is, so to speak, under surveillance. News? To answer this question, we clicked on the “Here” button. And here's what we'll see.
We set up a search query - Webhook. And get the result.
We choose. And we see the only possible action "Make a web request."
We make the choice again. After that, we see the next form that you need to fill out. You can thus connect the selected RSS feed to your bot in Telegram.
Filling in the fields is as follows.
URL Paste this link here - https://api.telegram.org/botTOKEN/sendMessage. Instead of “TOKEN” you must specify a control key. Do you remember? We painted it blue.
Method. From the drop-down list, select "POST".
Content type. From the drop-down list, select the item "application / json".
Body. This field is for a request sent to Telegram. Thus, we will create a bot that takes news from RSS feeds and independently publishes them on the channel, which must be filled out with such a template.
{"chat_id": "@ channel_address", "text": "{{EntryTitle}} {{FeedUrl}}"}
The first part of the template - everything is clear here. It is necessary to indicate where the news will go. Primer_channel.
The second part of the template - here we set the message. If under the “Body” field you clicked on the “Addingredient” button, you will be shown all the possibilities. We chose two for the template. EntryTitle is responsible for displaying the title, and FeedUrl for the link to the news.
As a result, it turns out that the “Body” field is filled with the following information.
{"chat_id": "@ primer_channel", "text": "{{EntryTitle}} {{FeedUrl}}"}
This is how a window with completely filled fields looks like.
Now click on "Create an action" and go to the next window.
And we see this message. There is an on / off button for this option.
You can open the My Applications section and see that the action is being created and it is active.
All you need to do to automatically publish news from RSS feeds by the bot. It remains only to wait until the news begins to appear on the channel. It should be noted that there is a delay between the appearance of material in the RSS feed and on the channel. The difference can be up to 1 hour. Therefore, if you saw that there is news in RSS, then for some reason it is not on the channel - you should not look for an error. You just have to wait a bit.
How the results of the work look, you can see in the screenshots.
RSS feed, list and list of information added to the feed