Hey there, Dev.to community! š Iām AltuÄ, and today Iām excited to share a fun project I built using n8n: a Telegram news bot named Laubali. This bot lets you get news summaries on Telegram by simply typing a category (like "/sports"), and it even adds a funny or slightly cheeky comment to each summary! š Letās dive into why I started this project and how it all came together.
Whatās n8n and Why Should You Care?
If you havenāt heard of n8n yet, youāre in for a treat! š n8n is an open-source automation tool that lets you connect apps, APIs, and services with a visual, no-code interface. Think of it as a magical bridge that ties your favorite tools togetherālike Telegram, NewsAPI, or even Slackāwithout writing a single line of code (unless you want to!). With 86k stars on GitHub, itās a community favorite! š You can use n8n to automate repetitive tasks, build bots (like Laubali!), send notifications, sync data between apps, or even create complex workflows. Itās perfect for developers who want to save time and have fun while doing it!
Why Did I Start This Project?
Letās be honestāthere are a million ways to get things done these days. As developers, keeping up with new tech and adapting is crucial. Some tools make our lives so much easier, even if they take away a bit of the āchallengeā vibe. But at the end of the day, we all need to finish our tasks quickly and get paid, right? Thatās why I decided to explore n8n, a powerful automation tool.
My motivation was a bit more personal: I was tired of spending hours browsing news sites or endlessly scrolling on Twitter (or X) for updates. I thought, āWhy not build a simple news catcher?ā And by doing it through Telegram, I could get quick summaries and get on with my day! Thatās how Laubali came to be.
Why Choose Telegram?
The biggest reason I chose Telegram is that its APIs are completely free. Instead of building a web app, I found it much easier to just open Telegram, type a message (like "/sports"), and kick off the workflow. I usually read news when Iām out and about, not at my computer. Sending a quick message from my phone to get summaries felt like the perfect solution.
Plus, Telegram has some awesome features! š Itās fast, secure, and offers cross-platform supportāso it works on your phone, tablet, or computer. Also, Telegramās bot API is incredibly flexible. You can create a bot with BotFather in minutes and integrate it with n8n. For users, itās a big win: just type a message and get news summaries instantly, right from your phone or any device!
The Fun Side of Laubali: Cheeky Comments
One of Laubaliās standout features is the funny and slightly cheeky comments it adds to each news summary. Wondering why I added this? Well, itās a bit of a social critique. š In my country, even during the toughest times, some news anchors make the most casual and tactless remarksāitās almost absurd. So, I decided to poke fun at that by naming my bot āLaubaliā (which means ātactlessā in Turkish for this case) and adding a witty comment to every summary. This feature really spices up the user experience.
Caching Mechanism: Why and How?
While designing Laubali, performance and cost management were key for me. n8n is free, but the AI Agent we use in this project (to summarize news and add comments) isnāt. Many of you reading this might be drawn to a āfreeā setup, but resource management matters! Thatās why I decided to add a caching mechanism.
The cache ensures that when the same category (like "/sports") is requested repeatedly, we donāt keep hitting NewsAPI and the AI Agent. Instead, we pull the data from the cache. This reduces API call costs and speeds up responses for users. For the first iteration, this solution works perfectly, but Iām sure some of you will add more advanced caching solutionsālike using Redis or Supabase. I kept it simple for now.
Technical Challenges and What I Learned
For someone familiar with n8n, this project would probably take 2-3 hours to complete. But for me, the most challenging part was digging into n8nās nodes and features by reading the documentation. n8nās docs are pretty comprehensive, but understanding how each node works took some time. The second biggest challenge was figuring out how to implement the caching mechanism using global data (staticData
).
We couldāve used docs, Google Drive, or a database for caching, but I wanted to keep things as simple as possible. The more features you add, the broader the projectās scope becomes. I thought, āIf this article gets traction, we can revisit those ideas later.ā š
The biggest lesson I learned came after finishing the project. Some people around me said, āWe could do this ourselvesāwhatās the big deal? Weād finish it in no time, no need for tools like this!ā But once the project was done, I realized something: Sure, a developer can build this easily. But when it comes to serving hundreds of users quickly at scale, n8n saves a ton of time and gets the job done. I truly appreciated the power of automation!
Prerequisites: Setting Up a Telegram Bot and NewsAPI
Before diving into how Laubali works, letās go over the technical setup youāll need to get started. To bring Laubali to life, youāll need two things: a Telegram bot and an API key from NewsAPI to fetch news. Donāt worry, both steps are super easy! š Letās get started.
Step 1: Create a Telegram Bot
Weāll use Telegramās official bot manager, BotFather, to create a bot. Hereās how:
-
Find BotFather: Open Telegram, search for
@BotFather
, and start a chat with the official BotFather account. (Look for the blue checkmark to avoid impostors! š) -
Create a New Bot: Send
/start
, then send the/newbot
command. -
Name Your Bot: BotFather will ask for your botās name and username. For example:
- Name:
LaubaliNewsBot
- Username:
@LaubaliNewsBot
(The username must end with "Bot.")
- Name:
-
Get Your Token: BotFather will give you an API token, something like:
123456:YOUR-TELEGRAM-BOT-TOKEN
. Save this token somewhere safeāyouāll need it to connect your bot to n8n. -
Test Your Bot: Go to your bot on Telegram and send
/start
. It wonāt do much yet, but itās nice to see itās ready! š
Thatās it! You now have a Telegram bot. Weāll use this token in n8nās Telegram Trigger
and Telegram
nodes.
Step 2: Get a NewsAPI Key
Laubali fetches news from NewsAPI, a great service for pulling news based on categories. To get your API key, follow these steps:
- Sign Up for NewsAPI: Head to NewsAPI and click āGet API Keyā to create an account. You can sign up with your email.
-
Grab Your API Key: After signing up, NewsAPI will provide you with an API key, like:
YOUR-NEWSAPI-KEY
. Save this key as well. - Test the API (Optional): You can test the API in your browser with this URL:
https://newsapi.org/v2/everything?q=sports&pageSize=5&apiKey=[YOUR_API_KEY]
This will return 5 news articles for the "sports" category. If you see a JSON response with news, youāre good to go!
Note: The free plan of NewsAPI has some limitations (like a daily request limit). Thatās why our caching mechanism will come in handy for this project! š
Step 3: Set Up n8n
Finally, make sure you have n8n installed. If youāre running n8n locally, you might need a tool like ngrok
to create a webhook URL (since Telegram needs a webhook URL to listen to your bot). If youāre using n8nās cloud version, youāll already have a webhook URL. For more details, check out the n8n documentation.
How Does Laubali Work?
Letās dive into the technical side of Laubali. When a user types a category (like "/sports"), the bot follows these steps:
-
Capture the Category: The
Telegram Trigger
node catches the userās message ("/sports") and theSet Interest
node stores it in theinterest
variable. -
Validate the Category: The
If Valid Interest
node checks if the category is valid (e.g., "/sports", "/technology"). If itās invalid, the user gets an error message. -
Check the Cache: The
Check Static Data
andIf Cache False
nodes check if thereās data in the cache and if itās less than 30 minutes old.-
If thereās cached data: The
Set Cached Summaries
node grabs the summaries, andsend cached message
sends them to the user. - If thereās no cached data: The workflow continues.
-
If thereās cached data: The
-
Fetch News: The
NewsAPI
node pulls 5 news articles for the selected category from NewsAPI. -
Summarize and Add Comments: The
Edit Fields
node formats the news, then theAI Agent
node summarizes each article and adds a funny comment. I also added aSimple Memory
to the AI Agent. Itās not actively used right now, but in the future, itāll help with conversational continuity (e.g., if the user says, āSummarize more sports news,ā it can recall the context). -
Cache the Summaries: The
Set Cache Data
nodes save the summaries to the cache. -
Send to the User: Finally, the
Send Message
node sends the summaries to the user.
This workflow runs smoothly and delivers results quickly, with the cache ensuring near-instant responses for repeated requests.
Why Should You Use Laubali?
For me, time is precious. Iād rather get daily news summaries quickly without wading through ad-heavy, toxic platforms, so I can focus on my day. When I want in-depth news, Iāll dive into those platforms and do my research. But for a quick daily summary while sipping my coffee, Laubali is the perfect solution! ā
Laubaliās best feature, in my opinion, is its simplicity and the ad-free experience it offers. Itās ideal for anyone who wants to stay informed quickly while having a bit of fun along the way.
The Future of the Project and a Gift for You
While working on this project, I realized that n8n is a gateway to a vast world of automation. But I intentionally kept the projectās scope small. I think this article provides enough lessons and examples for anyone looking to learn n8n and see a sample project in action. Laubali will stay active for a few days before I shut it down. But I want everyone to benefit from this project!
So, Iām sharing the entire workflow in a laubali-workflow.json
file: laubali-n8n-workflow.json. To use this workflow, copy the JSON content from the link, go to your n8n instance, and import it via the "Import Workflow" option. Make sure to set up your Telegram bot token and NewsAPI key in the respective nodes! You can load this file into your n8n instance to use Laubali as your own bot or build on top of it. Maybe youāll add a conversational loop, or perhaps a news verification featureāitās totally up to you! š (Remember the prerequisites, otherwise it WILL NOT WORK!)
Final Thoughts
Building Laubali was both a learning experience and a lot of fun. Exploring n8nās automation capabilities, simplifying my news consumption, and adding a bit of humor with a social critique made this project a joy to work on. I hope this article inspires you to create your own automation projects! What else would you add to Laubali? Iād love to hear your ideas in the comments! š
If You Want to Try This Project
If youād like to access and use this project, itās super simple! Just search for @LaubaliBot on Telegram and start using it. (I want to make it clear: this bot will never ask you for money or anything like that. There are a lot of fake bots on Telegram, so Iām warning you just in case you come across one!)