Welcome back to the how I built Blokfeed series! In this part I am going to run through the decisions, strategies, and services I used to send email alerts to Blokfeed's users.
Keeping up with news can be difficult, and what better way to stay up-to-date with daily emails containing articles you care about?!
Let's do this... โ๏ธ
From Part 3 we know what a user cares about because they have saved searches and filters, now we can automate pulling those saved searches and applying them to articles on a scheduled basis.
This was a perfect use case for AWS Lambdas. They are lightweight and can run on a schedule. To actually send the emails I set up AWS SES to do this. It's a little more complicated to set up, but had good pricing for my use case and was worth the extra effort.
The code is fairly straight forward. Find users that have saved searches and saved alerts turned on. Once I find these users and their saved searches I loop over the searches and grab matching articles. Where is gets tricky and is compiling this information into an email.
That's where I turned to handlebars to help compile the emails based templates.
Ok cool, I can pull saved results, compile and send emails, but what about tracking and seeing how my users are interacting with the emails?
This is where I used another small Lambda. As I compiled articles for users I also constructed internal tracking links. These links track via redirects where the other Lambda comes into play. I simply take the information from the link, redirect the user, and log which link they clicked on.
This information is important to know because it allows me to see how users are engaging with email alerts.
There you have it a simple workflow and set up for emails. I am leveraging AWS Lambdas quite a bit, as they provide simple compartmentalize bits of code that are easy to deploy, update, and schedule.
Depending on your use case you could look into SendGrid or Mailgun for sending emails. They have simple to set up API integrations, but do have different pricing models.
Next up in the series is how I set up Daily Briefs in Blokfeed. Any guesses to how I architected this? Let me know in the comments below.
Happy coding!