Create an AI Email Assistant in One Hour with Gmail, Zapier, and OpenAI GPT-3
--
Introduction
I’ve always wanted an assistant to help follow up with my team, plan my next trip, or brainstorm at any time of day. However, paying tens of thousands of dollars a year was out of reach for me. That’s when I came across OpenAI’s GPT-3 and its text generation capabilities and thought it would be a perfect fit.
Using Zapier and a custom GPT-3 prompt, I created a system that will look for new emails, process them through GPT-3, and then send the response back to the sender.
If you want to try it out for yourself, check out http://messagesam.com/
Detailed Steps
1. Setting up the Gmail Account
I found and purchased a domain with Google domains; then, I set up Google Workspace with a dedicated email that will serve as my assistant.
🔥 Hot Tip: You may want to setup some filters in Gmail so your assistant only receives and responds to you and not to non-named users.
2. Building the Prompt with OpenAI
I set up a dedicated account for OpenAI using my newly created email and got to work in the playground building the perfect prompt.
🔥 Hot Tip: I’ve found adding “Acting as ____” yields the best results when working with GPT-3
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
response = openai.Completion.create(
model="text-davinci-003",
prompt="Acting as my super fun and helpful virtual assistant named, Sam compose an email in response to the note received below \n\nFrom: [Name]\nSubject: Re: [Subject]\n\n[Body]",
temperature=0.7,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
3. Setting Up Zapier
I set up a Zapier account with the email and got to work on my first Zap.
Step 3.1: New Email in Gmail
This step listens for any new email received in Gmail’s Inbox and uses it to trigger the flow.
Step 3.2: Send Prompt in OpenAI (GPT-3 & DALL·E)
This step takes the key fields from the sender’s email (Name, Subject, Body) and inserts them into the prompt to be sent to Open AI.
Step 3: Reply to Email in Gmail
With this step, the system takes the response generated from OpenAI and responds to the user who sent the email along with anyone attached on the email.
🔥 Hot Tip: In the body text section, I did some additional HTML formatting to make the response feel more natural.
4. Results
I now had a personal assistant available 24/7 who could do the following: offer great recommendations, generate ideas, and improve the efficiency of daily life.
To find out more and try it out for yourself, go to MessageSam.com
❤️ Zach