I Created an Automated Medium Newsletter – Here is how you can do it!

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. You need a program that puts the stored data in the predefined templates and sends the resulting email to your subscribers.
  6. 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:

Screenshot of Cloud Firestore by author
Screenshot of Cloud Firestore by author

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 โœ…

Screenshot of the newsletter template with parameters by author
Screenshot of the newsletter template with parameters by author

It contains a forms editor to design subscription forms and has tools to manage subscribers โœ…

Screenshot of the Sendinblue forms editor by author
Screenshot of the Brevo forms editor by author

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:

Screenshot of the newsletter subscription form of Sendinblue by author
Screenshot of the newsletter subscription form of Brevo by author

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.

Screenshot of Sendinblue dashboard by author
Screenshot of Brevo dashboard by author

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.

Screenshot of the template editor of Sendinblue by author
Screenshot of the template editor of Brevo by author

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).

Screenshot of JSON example for the Sendinblue API by author
Screenshot of JSON example for the Brevo API by author

To get the template ID, look in your Brevo dashboard:

Screenshot of the Sendinblue Templates dashboard by author
Screenshot of the Brevo Templates dashboard by author

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.

Related articles