DEV Community

Cover image for How I built a COVID-19 newsletter with n8n (in just 5 minutes)
Alexander Schau
Alexander Schau

Posted on • Updated on

How I built a COVID-19 newsletter with n8n (in just 5 minutes)

The idea

My idea was quite simple. I wanted to build a corona newsletter, which sends me a daily email with the latest number of corona cases in my region, so I can keep myself up to date without checking multiple websites every day. To keep the whole project simple I also decided to use the open source workflow automation tool n8n.

The dataset

The biggest challenge at this whole project was the dataset. A simple method to get the data would be to just scrape the website of the local authorities and filter out the important stuff, but I wanted to challenge myself a little bit and build a tool, which will also work in other regions or countries. So, I started searching for a dataset with daily updates.

A dataset, which looked nice to me, was one provided by the European Union. The only problem with it: It doesn’t receive daily updates 😟.

After searching GitHub for a dataset, I found a, currently quite popular, repository of the Johns Hopkins University. It provides daily reports from many countries in the world and was thus my choice to go on.

The workflow

After finding the perfect dataset, I started building my workflow by adding a daily Cron node at 7am GMT, so I can get the latest data (they usually publish updates between 04:45 and 05:15 GMT)
Alt Text
After that I add a Function Item node, which formats the current date to the MM-DD-YYYY format, so we can use it as filename.

const date = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().split("T")[0].split("-"); = `${date[1]}-${date[2]}-${date[0]}`;
return item;
Enter fullscreen mode Exit fullscreen mode

Then I made a HTTP Request to get the file binary from the GitHub raw URL and convert the CSV file into JSON using the Spreadsheet File node.
Alt Text
The only thing, that’s left now, is to filter out the data of a region and sending it through email.

items[0].json.myVariable = 1;
return items.filter(item => item.json.Combined_Key == "Berlin, Germany");
Enter fullscreen mode Exit fullscreen mode

Alt Text

Final words

Seriously, I never thought it would be that easy to build something powerful like this. Next to the possibility to sending emails, n8n also support lots of other ways like Matrix or Slack, which allows you to send this newsletter to the place where you need it the most.

If you now want to build this project on your own feel free to use my code (you will find it on n8n’s website and on GitHub), but I really recommend you, to build it from scratch, because it’s incredible to build something like this in just 5 minutes 😁.

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.