I recently came across a tweet from a founder in my network, who had an interesting question on Twitter: "Why can't you email an assistant and just a get a response without any hassle?" Around the same time, I noticed a discussion on r/residency about GPT-4 being blocked across various hospital networks.
A few days later, I discovered that GPT-4 access is restricted in several countries, and private usage is quite limited. This prompted me to revisit some old code I had, which was designed to handle email webhooks for incoming messages. I decided to adapt this code to create a solution for these issues because it would be cool.
Thus, Assistant-OverMail was born—an open-source project aimed at simplifying access to GPT-4 via email.
Assistant-OverMail
Assistant-OverMail is an open-source web application designed to simplify your workflow by emailing assistant@overmail.ai (or any domain name if you self-host) and getting a response back from GPT-4.
You can use this to use GPT-4 privately, go around employers' blocks, or simply as a short-cut to deal with emails in the inbox. You can try it at: overmail.ai
For those interested in self-hosting, the setup requires Docker, Docker Compose, and a standard Nginx + SSL configuration. Assistant-OverMail is compatible with any email service provider that supports SMTP, such as Mailgun, SendGrid, or AWS SES. Just provide your SMTP credentials in the .env
file to get started.
How does it work?
The main business logic is really around emails webhooks. All mail providers as far as I know provide a way to send you webhooks on receiving emails that match certain rules. Here is an example from my mailgun dashboard.
In our case, whenever an email is sent to "assistant@overmail.ai", mailgun forwards this email as a form POST to a designated endpoint. This endpoint performs several checks before passing the email content to GPT-4 for processing. After generating a response, the system utilizes Django's built-in email capabilities to send this response back to the sender.
Parsing Email Addresses
One new thing I learned from trying to improve my old code is Python's parseaddr.
My old code had a big block of code handling all kind of different emails formatting on the FROM field with if
statements.
The parseaddr
function from Python's email.utils
module is used to parse a string into its constituent name and email address parts. It takes a single string argument, which typically represents an email address with an optional display name, and returns a tuple of the form (realname, email_address)
. Here's a quick breakdown:
Input: A string in the format
"Display Name <
email@example.com
>"
or just"
email@example.com
"
.Output: A tuple where the first element is the display name (if provided, otherwise an empty string), and the second element is the email address.
The function is quite handy for extracting email addresses and names from headers or similar formats in emails where such data may be presented in a more human-readable form.
Payments
Stripe checkouts are relatively straightforward. You generate a URL on the server from your Stripe key and the Price id, and redirect your user to that URL. They pay on Stripe infrastructure, and you get notified via a webhook on success.
I did want to experiment with Bitcoin payments though as something new to learn. This feature, ended up taking almost a week - mostly because I didn't know what I was doing (but now I do). It really deserves its own post, but at a glance - there are three ways you can accept Bitcoin payments over the internet, ranked by effort:
Via BTCPay server on your own infrastructure
Custodial services APIs (Alby or Strike for example).
Via a payment processor on their infrastructure
Since this is a small project that I wasn't looking forward to maintain a server for or build a custom checkout experience on top of Alby or Strike APIs- I ended up going with #3.
OpenNode is a Stripe-like service that essentially offers the same type of workflow for Bitcoin. A checkout URL is generated on the server, and the user is redirected there. They pay on OpenNode infrastructure, and you receive a webhook on success.
Frontend
This is a quite simple project, and so I decided to go with a Carrd template for it. All what was needed is really a form to submit an email address too, and everything else is either payment on someone's else infrastructure or a webhook.
Alternatives
There are a few Zaps from Zapier that offers Email to GPT-4 integration. There is also at least 1 extension that works in the browser to autofill email responses.
I consider this project complete and overall a success. You can find the completed project here: https://overmail.ai and the code - MIT licensed here: https://github.com/Jonathan-Adly/assistant-overmail/