All you need is some coding skills, your Medium RSS feed, a database, and a scheduler to run your code regularly. Here are all the details!
Medium readers can subscribe to writers and get notified by email when a new article is published. I like the feature but it also leads to a lot of emails flooding my inbox. Sometimes I wish I’d get fewer emails but still don’t miss anything important.
So I sat down and began coding. The result is a monthly newsletter that contains a short summary of all my published articles of the previous month. The subscriber receives just one email at the beginning of every month instead of 8-12 emails during the month (depending on how much I publish).
?
Hint
The most amazing thing is that all tools are free, I don’t pay anything for the entire workflow!
If you are curious about what it looks like and how you can subscribe, read my announcement article about the newsletter.
?
Tip
This tutorial works for any blog or site with an RSS feed. But the feed is just one way to get the data. If you can get the information via an API, you can adapt the guide to suit your needs.
I want that! What do I need to do?
Follow these steps to create your own custom Medium newsletter. I’ll explain every step in detail in the following sections.
- You need to create a program that extracts information from your Medium’s RSS feed. This feed contains article titles, abstracts, links, tags, images, and the published date.
- You need a database to store the extracted information. Since the data is not secret, you can go for any cloud database. But you can also choose a local approach.
- You need an email service with an API to send emails to your subscribers. I chose Brevo*. They offer customizable email templates. More on that later.
- You need to get subscribers. I don’t recommend using your existing subscribers for the new system without their consent. Many email services offer customizable subscription forms that you can use.
- You need a program that puts the stored data in the predefined templates and sends the resulting email to your subscribers.
- You need a scheduler that is executed regularly (e. g. once a month).
It sounds not that easy. But I’ll give you all the hints you need to accomplish the task.
?
Tip
* All Brevo links are affiliate links. If you sign up with this link I receive a small commission if you create an account or choose a paid plan. You don’t have any additional costs!
Extracting the data
Without data, there is nothing to send. So we need to find out how to get the information for our subscribers. Medium automatically creates an RSS feed for every writer and we can grab the information from it. I wrote an article explaining the Medium RSS feed in detail. As it is a web standard, all feeds have a similar structure.
You can use any programming language you want like Python, JavaScript, or Dart. I use C#. Here is some code to inspire you. You need to think about removing HTML tags, finding the correct images, and distinguishing between free and paid articles.
Filling the database
The Medium RSS feed has one major flaw: It only contains the latest 10 articles of a writer. If you don’t plan to publish more between two newsletter emissions, then it would be possible to live without a database. But a database is also useful if you want to use your collection for other purposes (like creating a custom profile page with selected articles).
You can use any database you want. I chose Cloud Firestore from Google Firebase as I worked with the system a lot in the past. If you don’t know anything about Firebase, here are some articles about various services:
There are many other cloud providers with databases like Microsoft Azure or Amazon Web Services. You can also use a local database. It’s totally up to you. Just make sure that your code can access it.
Here is a screenshot of what the filled database can look like:
If you publish often, you need to run your code from the first step regularly, so that all articles are stored in the database before they get overridden. One approach is to use a build pipeline that builds your code and runs it once a day. Think about Azure DevOps or GitHub Actions. Another idea is to write a cloud function in Firebase or Azure. This works of course only if the cloud provider supports your programming language. A third option is to run your program on your local server if you have one via a cronjob. With that approach, you are completely independent of any third-party service.
In my case, I chose Azure DevOps since I use C# to extract the data. The pipeline runs once a day, builds the app, and runs it. The app then grabs my Medium RSS feed and inserts new data into my Cloud Firestore instance. That way, I won’t be at risk to miss articles in my newsletter.
Level up your Firebase skills!
Check out my free email course on Firebase fundamentals, and grab your copy of my Firebase ebooks. Start building amazing apps with Firebase today!
Choosing an email service
The email service is an essential part because it needs to have several features:
▶ It should provide an API to send emails from code
▶ It should provide any kind of system to customize emails from code
▶ It should be able to collect and manage subscribers
▶ It should be cheap
I evaluated some services like MailChimp, OctopusEmail, ConvertKit, and others. But only Brevo provides all the features that we need. There may be other services but I stopped searching after my test with Brevo was successful. The mentioned competitors didn’t provide an API to send emails.
It contains an API to send customized emails to subscribers → Link ✅
It contains a template editor to design emails and add placeholders for changing values ✅
It contains a forms editor to design subscription forms and has tools to manage subscribers ✅
The free plan allows sending 300 emails per day → Link ✅
That’s all we need. ?
Collecting subscribers
Brevo has a forms editor to create subscription forms. Use it to promote your newsletter and collect subscribers. Here is a screenshot of my subscription form to give you an idea:
You can find your Forms editor in the Brevo dashboard by clicking on Contacts → Forms. When adding or editing a form, the editor will pop up.
Filling out the email template
We grabbed the data and collected subscribers, but we are still lacking an email template for our newsletter. Brevo provides a template editor with parameter support. Those parameters can be set with an API request before sending the email.
To get the email addresses of your subscribers, you can use another API endpoint. It requires the ID of your subscriber list (you can find it in the Brevo dashboard under Contacts → Lists) and returns the data of the subscribed users.
To create parameters in the template, insert the code {{params.headline}}
at the desired location. It can be a title block, a part of a text block, or even an image URL. The API call should include a section in the JSON body called params with a key-value pair (see an example from the documentation below).
To get the template ID, look in your Brevo dashboard:
My template contains placeholders for 15 articles (I usually publish between 8 and 12 per month, so this should be fine). To hide unnecessary sections of the email, I use a condition to hide them (see the eye symbol in the first screenshot of this section). By default, all sections are hidden. With the parameter showArticleX
, I toggle the visibility of the block. If this parameter is missing for some articles, those blocks won’t be changed. So I can make sure that if I published 12 articles only 12 placeholders are visible and the other 3 stay hidden.
Here is some example code to create the params
section of the request body:
?
Tip
Brevo has a preview function but you can also use Postman or curl and make a request against their API. Create a list of test users or use your private email account for testing.
Scheduling the execution
As I mentioned earlier, I use Azure Pipelines for the scheduling part. Therefore, I created 3 pipelines:
- Pipeline 1 runs daily, parses the RSS feed, and adds new articles to my Firestore database. Remember that an RSS feed usually only shows a finite number of entries. To not miss any articles, we store their data in a persistent database.
- Pipeline 2 runs on the first of every month to send the email newsletter to my subscribers. In my case, the sending period is monthly. If I decide to switch to a weekly schedule, I only need to change the execution interval of the pipeline.
- Pipeline 3 runs a few hours before pipeline 2 to test the resulting email. Sometimes, there are problems with special characters or formatting issues. This test gives me time to fix problems or postpone the actual newsletter until everything is fine again.
You can however choose any scheduling approach you like. I am just very comfortable with Azure DevOps, so I chose this platform. With that, your automated newsletter is finished.
Conclusion
With this guide, you can create your own automatic Medium newsletter and save your subscribers from overflowing email inboxes.