Introduction:
Managing a large volume of emails can be a daunting task, especially for businesses that require prompt and professional communication. To address this challenge, we’ve devised an innovative automation using GPT-4, Google Sheets, and Google Apps Script. This solution streamlines the process of drafting email replies, saves time, and ensures consistent communication. In this blog post, we will guide you through the steps to implement this automation and provide you with the make.com blueprint, Google Apps Script code, and an instructional video.
In our automation solution, we provided GPT-4 with a carefully crafted plain-text prompt to generate contextually relevant and friendly email replies. The prompt was designed to instruct GPT-4 to draft a response as if it were the business owner, Courtney Lyons, and to use a grade 4 reading level to make the response more relatable.
The prompt included placeholders for the recipient’s name, email body, business information, and other relevant details. It also instructed GPT-4 to assess the content of the email and determine whether including a link to book an appointment would be relevant. By providing GPT-4 with these specific instructions, we ensured that the AI-generated replies would be tailored to each unique email, addressing the specific needs and concerns mentioned.
By leveraging the advanced language capabilities of GPT-4, this automation solution delivers personalized, professional, and friendly email responses that cater to the individual needs of each customer while maintaining a consistent communication style.
This was my prompt;
As the owner [owner name], please draft a friendly and professional email body in response to the following email using a grade 4 reading level. Use the provided business information to address the specific needs and concerns mentioned in the email. Make the response very relatable. Assess the content of the email and determine if including a link to book an appointment is relevant it isn’t always. If so, include the link in the response. Pull the recipient’s name from the sender of the email provided.
Email sender name: [Customer Name]
Email body: [Body of the received email]
Business information:
- Business name: [Business Name]
- Address: [123 Main St, City, State, ZIP]
- Phone: [123-456-7890]
- Email: [info@example.com]
- Website: [www.example.com]
- Category: [Category]
- Appointment link: [www.example.com/appointment]
Step 1: Set up the Google Sheet
Create a new Google Sheet to store email IDs, relevant business information, and GPT-4 generated responses. Structure your sheet with the following columns:
A. Email ID
B. Subject
C. Body
D. Business Name
E. Address
F. Phone
G. GPT-4 Generated Reply
H. Draft Status
Step 2: Integrate GPT-4 and Make.com
To generate contextually relevant email responses, you’ll need to use GPT-4. Integrate GPT-4 with Make.com, and use the plain-text prompt provided earlier in this conversation to instruct GPT-4 on generating the email replies.
ntegrating Make with Gmail, OpenAI, and Google Sheets is an effective way to set up a smooth automation workflow for managing email replies. In Make, you created a module to perform the following tasks:
- Accept new emails in Gmail: The module monitors your Gmail account for incoming messages, ensuring that the system stays up-to-date with the latest customer inquiries.
- Filter emails: By applying a filter, the module excludes notifications and newsletters, focusing only on relevant customer emails. This ensures that the automation solution concentrates on creating drafts for genuine inquiries.
- Send filtered emails to OpenAI: Once the filter is applied, the module sends the filtered emails to OpenAI’s GPT-4 for generating contextually relevant email replies, using the carefully crafted prompt provided earlier.
- Add new rows in Google Sheets: After GPT-4 generates the email replies, the module adds a new row to the Google Sheet for each email. These rows include the email ID, subject, body, business information, GPT-4 generated reply, and draft status.
By setting up this module in Make, you’ve created a seamless automation process that efficiently handles incoming emails, leverages the power of GPT-4 to generate personalized responses, and organizes the data in a Google Sheet. This not only saves time but also ensures consistent and professional communication with your customers.
Step 3: Implement the Google Apps Script
Copy and paste the following Google Apps Script code into your Google Sheet’s script editor:
function createDraftReply() {
var sheet = SpreadsheetApp.getActive().getSheetByName("Sheet1");
var data = sheet.getDataRange().getValues();
for (var i = 1; i < data.length; i++) {
var emailId = data[i][0];
var reply = data[i][6];
var draftStatus = data[i][7];
if (emailId && reply && !draftStatus) {
var draft = GmailApp.createDraft(emailId, "", reply);
sheet.getRange(i + 1, 8).setValue("Draft Created");
}
}
}
This script, titled “createDraftReply,” performs the following actions:
Accesses the Google Sheet and retrieves the data.
Iterates through each row, starting from row 2.
Extracts the email ID, GPT-4 generated reply, and draft status from each row.
If conditions are met, it creates a draft in Gmail with the GPT-4 reply.
Updates the draft status in the Google Sheet to “Draft Created”.
Step 4: Run the Script
To execute the script, simply run the “createDraftReply” function from the script editor. It will create drafts in your Gmail account based on the GPT-4 generated replies and update the Google Sheet accordingly.
By combining GPT-4’s power to generate contextually relevant email replies, Google Sheets for data organization, and Google Apps Script for automation, this solution simplifies email management and ensures professional communication. Follow the steps provided, use the make.com blueprint, and watch the instructional video to implement this automation and enhance your email management process.