News filtration and aggregation with telegram bot and Yandex Cloud Functions

2022-05-31, Anton Bakuteev

Reasons

Most of us at some moment of time struggle with overload of information. We have messengers, accounts in social networks, and use recommendation engines (like Google Feed or Yandex Zen). Each of these sources has a lot of unimportant news and spam, so it became very easy to skip something really important. For example, in my case at this period of time information about significant changes of exchange rates is very useful to know. So, I created a telegram bot which collects news from different sources, filters them by keywords and sends notifications with filtered news in telegram. Bot checks information each hour to prevent distractions. This bot really helps to decrease informational overload and helps to concentrate on more important things.


Implementation

First of all, you need to create a bot and get its token. It is very easy to do with @BotFather. Then you need to create a cloud function to parse rss feeds. I’ve chosen Yandex Cloud since it is cheap and has convenient and flexible cloud functions. Code of function is here. It uses environment variables which you need to specify in corresponding fields. To make it work you need to fill news sources and keywords. There is a list of rss urls in the news_sources field. You can change it to your own. Just open your news source website and search for rss on its page or just google it. KEYWORDS is an environment variable. It is a string which consists of keywords or phrases separated by commas with no extra spaces.



As you can see, I use the channel name as TELEGRAM_ID. You also can create a channel and give bot write permission, or you can just use your own ID (but of course you need to start bot before it).

To make it run on a schedule you need to create a trigger.



That is all! You are ready to use it.


Conclusion

It is very easy to create your own news filtration and aggregation bot and it is really helpful. But if you don’t want to spend time on development you can use a more advanced version of bot https://t.me/ai_filtered_news_bot. It supports multiple users and supports commands for setting keywords and news sources. And it is completely free!

Copyright © SomeTech™ 2023