~~~ This post was originally published in my blog ~~~
The Nudge
I receive a lot of links on my mobile phone and more often then not, I forget about these links and end up missing content that I was looking forward to reading. I also wanted to make the Kindle as the my primary reading device.
I was using Pocket to save links and did explore the possibility of using ifttt to send links saved in pocket to my kindle device. It didn't work that well for me :/ there are a few other options https://help.getpocket.com/article/1127-using-pocket-on-kindle-devices, but they didn't seem very mobile friendly.
Save to Kindle is the official chrome extension that does a very decent job of sending articles to your kindle, I couldn't find an equivalent mobile app for it.
I did come across https://p2k.co/ and the free plan seemed to fit the bill.
Oh hell, I think at this point you're probably thinking that i just wanted to build something and was making up reasons for it. You aren't wrong.
Architecture
The goal was to have a simple interface to send articles to my kindle and in my head, this how I was thinking about it.
I didn't want to install / build another app and have the hassle of publishing, installing and pushing updates. I wanted to use an existing app and it would be a choice between using Telegram and Whatsapp (apps where sharing was easy). Telegram (at the time of writing ) had a better bot framework and it I could see that there were libraries in multiple languages that supported Telegram.
While technically not an architectural decision (or is it? https://martinfowler.com/bliki/TwoHardThings.html ), I decided to name the bot Hermes.
In association with his role as a psychopomp and god who is able to easily cross boundaries, Hermes is prominently worshiped as a messenger, often described as the messenger of the gods (since he can convey messages between the divine realms, the underworld, and the world of mortals).[35] As a messenger and divine herald, he wears winged sandals (or, in Roman art influenced by Etruscan depictions of Turms, a winged cap).
Components
Communicating with Kindle
I couldn't find a Kindle API, and the only reliable way to send content to Kindle was by e-mail
Every kindle account gets a Send-to-Kindle e-mail address. Attachments mailed to this email id, automatically get synced to your kindle.
You have to list the email id from which you'll be sending content in the "Personal Document Settings" section.
Choosing a bot framework
I came across https://telegraf.js.org/#/ and the examples and documentation were neat and immediately gave me multiple ideas on how I could structure my app.
While at this point, I hadn't chosen a programming language nor my deployment platform. Telegraf's easy to use API and the fact the deploying a Nodejs app on Heroku is something I've done before, I felt that an express app on Heroku would be the fastest and easiest way to build my bot server.
Setting up a Mailer
Since the only way to send to Kindle was by Mail. Choosing a mailing service became a critical.
My only criteria for choosing a mailer was that it should be free. SendGrid's free plan - "Send 40,000 emails for 30 days, then 100/day forever." was more than adequate for my requirements.
Extracting Article Content
Not all HTML content can be rendered on the Kindle, and I wanted to ensure that only the text content is sent to kindle and didn't want my device glitching.
I came across - https://github.com/ndaidong/article-parser a node package that extracts content from website. It worked beautifully.
Code
https://github.com/koundinya/hermes
Fin
Bot Interface -
On My Kindle -
Top comments (0)