Automate email reply or draft reply with the ChatGPT and Google Apps Script
Introduction
In this Google Apps Script project, I am using ChatGPT to generate a reply message by providing the messages in the Gmail thread. The reply can be then sent out directly or created as a draft so you can review before sending it out. Check my introduction on YouTube if you prefer to watch.
Setup
Make a copy of my project
Complete the authorization
Run “Setup
” wizard.
Set your name so the ChatGPT knows who you are and add your name to the reply email as signature.
Set the email check interval, you have 1, 5, 10, 15, and 30 mins as options.
Set your OpenAI API key
You should see this message if your API key is valid. It will save your inputs as settings and create a trigger to check your Gmail account automatically.
Set rules in the tab “Rules”.
Gmail Query
– Check this document if you are not familiar with the syntax.ChatGPT Prompt
– The prompt will be prefixed to the messages of the email thread.Messages
– The count of messages to be included into the prompt to be sent to ChatGPT.Reply All
– Reply to all contacts in the thread or only reply to the sender.Reply in Draft
– Create a draft reply to the thread instead of sending it out without checking. When it’s checked,Reply All
is ignored.Enabled
– Enable or Disable the rule.
Other Features
Run
– Check your emails manually for the enabled rulesAdd sample rule
– Add a sample rule to the sheet “Rules”Reset
– Disable the automation and remove your settingsVersion
– Check project versions