Using Email and Val Town to Draft Blog Posts
• ~400 words • 2 minute read
Lately I've been playing around with Val Town. Their pitch is something like "If AWS Lambdas were fun" and—despite being unable to articulate what that even means—I have to chuckle and nod. It's a great product that I've really enjoyed using the past few weeks.
Two things in particular have been great about it:
- Free OpenAI access. It's already pretty cheap to play around with LLMs on most platforms right now, but you can't beat free.
- Email-driven workflows. I think I find this more compelling than the average person, and the ease with which you can setup scripts that are triggered by inbound emails on Val Town caught my attention.
In fact, this post started life as a document I emailed to one of those scripts!
How it works
- We send an email to a special Val Town email address. Under the hood, I think Val Town is using SendGrid to route these emails to my script—specifically their Inbound Parse Webhooks.
- The script takes the plain-text email content and creates a new draft in my blog's GitHub repository using Octokit.
That's pretty much it?
Noteworthy
- This workflow assumes you're using some sort of static site generator and storing your content in GitHub. There are many to choose from in this space. I'm partial to 11ty.
- Gmail is doing some heavy-lifting for me here in terms of kindly converting my HTML email to Markdown behind the scenes. There's no guarantee all email providers do this. If yours does not, you may have to investigate an HTML-to-Markdown conversion step.
- It uses the GitHub API via Octokit to create the file. You'll need to create a personal access token and store it an an environmental variable in your Val Town settings.
Other services in this space for inbound-email processing:
What's next
I want to try and recreate this workflow with Cloudflare Email Workers. I finally figured out how to get those working this weekend despite the documentation omitting what felt like a lot of important details.
There is a side-project/product I'd like to pursue in this space, and while Val Town is a lot of fun for a quick-and-dirty MVPs (or even IMPs) I'd be nervous trying to run anything resembling areal business on it.
Stay tuned!
The Code
If you're on Val Town and want to give it a fave or a fork you can find the script here: