Create Gmail Replies or Drafts with ChatGPT

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”.

  1. Gmail Query – Check this document if you are not familiar with the syntax.
  2. ChatGPT Prompt – The prompt will be prefixed to the messages of the email thread.
  3. Messages – The count of messages to be included into the prompt to be sent to ChatGPT.
  4. Reply All – Reply to all contacts in the thread or only reply to the sender.
  5. 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.
  6. Enabled – Enable or Disable the rule.

Other Features

  1. Run – Check your emails manually for the enabled rules
  2. Add sample rule – Add a sample rule to the sheet “Rules”
  3. Reset – Disable the automation and remove your settings
  4. Version – Check project versions

Check on YouTube

Links

Follow Me on YouTube

Google Apps Script Playlist

Hire Me on Upwork

Source code on Github

Leave a Comment