In this video I build a low-code AI system that writes and send amazing email replies for me.
The average office worker spends around 5 hours a day checking, reading and writing emails.
Which means if you could magically eliminate the need to ever deal with emails again, you’d have 5 additional hours each day to… "Work more".
So I embarked on a mission to see if that was even possible. And what I discovered blew my mind, and it’s gonna blow yours too.
So let’s circle back to where it all started.
A few months ago I came across an AI System called Dall-E that could create realistic images and art from a simple text description.
And naturally, the first thing I asked it to create was a Studio Ghibli style digital illustration of a cat wearing an ushanka holding a dimly lit oil lamp…
And it created something shocked my cat-loving Russian girlfriend and I…
So as you can imagine, I dove head first down the AI rabbit hole.
And when I emerged on the other side, I found myself… in a playground.
Not the type of playground where kids discover gravity.
A playground that lets you interact with OpenAI’s GPT3, an artificial intelligence system that is insanely powerful.
And at this point my brain was bursting at the seams with ideas.
All I could think about was building something that harnessed and leveraged the power of this AI.
So I wrote down a few options, and decided emails were the way to go (since they’re the bane of every professional’s existence).
And after a little research I discovered a study by Adobe that said the average knowledge worker spends over 5 hours a day checking, reading and writing emails.
Which is where I got the first line of this video from.
But then I saw this line.
“Fewer people are achieving Inbox Zero, and many think it's an impossible goal.”
So there it was, my mission laid out clearly in-front of me.
I needed to create some sort of system that would use AI to help people achieve inbox zero.
A pretty ambitious task.
Especially since I can’t code.
But what I can do… is think.
And if you can think, you can build whatever your mind can imagine.
That’s the magic of being a low-code developer.
You can drag-and-drop your ideas into existence without coding.
So Operation Inbox Zero was set in motion, and I had a few rules.
And to stop me from chronically over-engineering like I always do, I decided that version one of this system had to perform one task, and one task only.
Write and send intelligent replies.
Is that technically two tasks?
Could it be done?
I had no idea.
Was it worth finding out?
So I started building.
And building involved 2 steps.
Step number 1 was to create powerful and reliable prompts.
Now, here’s a massively oversimplified breakdown of how a tool like OpenAI works.
You give it a text prompt, and it returns a text result.
So if you ask it a question, you get an answer.
If you start a sentence, it finishes that sentence.
If you ask it to write an email, it writes an email!
But a poor prompt will give you a poor result.
So the first challenge was creating a powerful and reliable prompt that told OpenAI to read an email and create an intelligent reply.
Now there are a million ways you could reply to an email, but for the sake of brevity and this experiment, I came to the conclusion that there are 5 fundamental types of replies.
Replies that say yes, confirm or agree.
Replies that say no, decline or disagree.
Replies where you elaborate on something, make a choice, or make a decision.
Replies that wrap up a conversation by acknowledging or thanking the sender.
And replies that let the recipient know you’re working on their request and will get back to them asap.
So we’ve got 5 different types of replies and they do 5 different things:
Agree, Disagree, Elaborate, Thank, or Defer.
And there are probably better names for each type, but let’s just roll with what we’ve got.
Now all I had to do is create the prompts that tell OpenAI create each type of reply.
And here’s how I did that.
I jumped into the playground.
Wrote a prompt.
Pasted an example email that I wanted it to create a reply for.
Hit submit and reviewed what came back.
If I was happy with the response, I’d paste another example email and hit submit.
And I repeated this process until I fed it an email that broke the prompt or gave me a response that wasn’t ideal.
At which point I’d tweak the prompt or parameters, and run the experiment again with the same set of emails until it created the desired outcome every time, no matter the email it was fed.
And after a few hours of testing and tweaking, here are the 5 prompts I settled on.
curl https://api.openai.com/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
Your name is Marco. Write a professional and polite reply to the following email that says yes to their question, accepts their offer, or agrees with their statement. Make sure it's short and succinct, and remember to sign off with your name.
Your name is Marco. Write a professional and polite reply to the following email that says no to their question, declines their offer, or disagrees with their statement. Make sure it's short and succinct without being rude, and remember to sign off with your name.
Your name is Marco. Write a polite and enthusiastic reply to the email below that expands on the bullet points below. Spread any long passages of text over multiple lines. Ensure you incorporate each bullet point into the email, and sign-off with your name.
Your name is Marco. Write a succinct and casual reply to the following email thanking them. Remember to sign off with your name.
Your name is Marco. Write a short reply to the following email reiterating their points and letting them know that you will respond to them shortly. Remember to sign off with your name.
So! I I now had a handful of powerful and reliable prompts that gave me consistent and useful replies to any email they were fed.
But how do I feed OpenAI my emails?
And how to does OpenAI then create a reply and send the email on my behalf?
I certainly wasn’t going to copy and paste every email and reply, going back and forth between the two apps…
So that’s where step 2 came in, Connecting OpenAI to my Gmail.
And to get that ball rolling, the first thing I did was jump into Gmail and create 5 labels named after the 5 reply types I defined earlier.
Agree, Disagree, Elaborate, Thank, or Defer.
You can think of these labels as folders, and the idea behind them was simple.
Whenever I dragged an email into one of these folders, OpenAI would somehow analyze that email, create an intelligent reply using one of the 5 prompts I created earlier, and send that reply.
So if I dragged an email into the Agree folder, it would analyse that email and reply with an email that confirms or agrees.
The same goes for the Disagree, Thank, and Defer folders.
The Elaborate folder was a little less straight forward.
Because if the email demands a nuanced or specific answer, you’d need some way of telling OpenAI what you want the email to say.
For example, if someone asked you if you’re free for a meeting at 3pm on Monday, and you are, you could just drag it to the agree folder and OpenAI take care of the rest.
But if someone asked you when you’re free for a meeting.
You’d need some way of telling OpenAI that your reply should let the other person know that you’re free on Monday at 3pm.
So my solution was to hit the reply button first.
Create a draft response with a few bullet points, and then drag it to that folder.
From there, OpenAI could expand on those bullet points, create a perfectly diplomatic and polite reply, and send it!
Not 100% automated… But still pretty efficient.
So now it was time to actually connect Gmail to OpenAI.
And that’s where Make came in.
Make is a beautiful tool that lets you connect apps together and automate tasks.
I can do a video on Make another time, but for now, here’s how I connected Gmail to OpenAI.
First, I told Make to watch these 5 Gmail folders.
Then, when it detects that an email had been dragged into one of these folders, a JSON module would add the body of that email to one of prompts I created earlier.
This creates a new prompt that can be sent to OpenAI.
And to do that, I added a HTTP module.
Then I jumped back in the playground, clicked view code, selected curl, and pasted this information back into the HTTP module I just created.
If you want to do this yourself, here’s how.
Paste this URL into the URL field at the top, select POST, then add two headers.
In the first you’re going to paste Content-Type in the name field, and application/json in the Value field.
In the next header you’re going to paste Authorization in the Name field, and Bearer + your OpenAI API key in the value field.
You can find your API key by clicking here and hitting copy.
It’s a good idea to keep this hidden.
Then you want to select body type as RAW, content type as Application JSON, and in the Request content, you want to copy everything between these two apostrophes, including the curly braces, and paste it.
But before you click OK, you want to delete the prompt it comes with, and replace it with the new prompt you created the step before.
And that’s it!
Your request is now ready to be sent.
And when it’s sent, OpenAI will respond with a long line of text.
But we don’t want to send an unformatted email without new lines or paragraphs.
So what we need to do is convert this string into HTML using a “Markdown to HTML” module.
And NOW the reply is ready to be sent, which means it’s time to add another Gmail module.
And this time, we’re going to select the “Send An Email” module.
If you don’t fully trust OpenAI to reply on your behalf (which you probably shouldn’t) you could always change this to “Create A Draft” so you can review each email before it gets sent.
But in my case, I wanted to automate as much as possible, so I skipped that step and went all in.
I selected the original sender as the recipient, added RE to the subject line, and used the new HTML reply I created in the step before as the body of the email.
And that’s it!
Just duplicate and tweak this scenario for the 4 remaining folders in Gmail and you’re done!
You’ve successfully built an AI system that intelligently replies to any email you feed it.
Saving you a boat load of time and helping you achieve the elusive inbox zero!
The only thing to note is that there are thee extra steps in the Elaborate scenario. One that extracts your bullets from the conversation, one that extracts the original email, and one that deletes the original draft you created once the email is sent.
Let’s give it a go.
So here’s an email sitting in my inbox.
And the Elaborate automation is the most complex, so let’s test that one.
I’ll hit reply, and paste a few quick bullets.
I’ll drag it to the Elaborate folder, and my inbox is clear!
Now usually Make will run this automation every 15 minutes, but for testing purposes I’ll run it manually now.
The automation has started.
It’s talking to Open AI…
And the reply has been sent.
Let’s see what it sent.
Yes we do, Bob!
We would be happy to discuss our development services with you.
Please give us a call at 0411 411 411 at 3pm on Monday.
We look forward to speaking with you!
All the best,
So there you have it!
An AI system that can write and send intelligent, nuanced replies.
Now, does this actually remove the need to ever send an email again?
Is it going to read your mind and write exactly what you want it to?
Again, probably not.
But it was fun to build, and if you tweak it suite your needs it might just help you achieve inbox zero.
I mean, you could turn this system into an absolute powerhouse.
You could add the ability to create cold emails, send automatic follow ups, turn emails that require action into a list of todo’s, anything!
The only question is… what will you build?