Create Gmail Replies or Drafts with ChatGPT Automatically: GAS105

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, you can add multiple rules in the Google Sheets to handle different situations with different prompts to ChatGPT.

YouTube

Check this project introduction video on YouTube if you prefer to watch video instructions.

Instructions (4 Steps)

Follow the steps below to set up your own project, please note the OpenAI API key is not provided in the project, you have to create your own by using this link.

https://platform.openai.com/account/api-keys

Step 1

Make a copy of my project here to your Google Drive.

Step 2

Complete the authorization step by clicking any of the buttons from the menu “GAS105”. Follow the guide below if this is new to you.

A Complete Guide to Authorize GAS Project

Step 3

Run the “Setup” wizard from the menu “GAS105”.

Enter your signature for the email to be sent out.

Set the interval for checking the new emails in your Gmail account.

Enter your OpenAI API key to get started.

Error message when the API key is invalid.

Step 4

Once you have the setup done, you can add your rules in the tab “Rules”. And the script will check your inbox automatically, a reply or a draft reply will be created with the content from ChatGPT if any rule matches.

  • Gmail Query: check this reference 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” will be ignored)
  • Enabled: enable or disable the rule

Other Features

  • Run: Check your emails manually for the enabled rules
  • Add sample rule: Add a sample rule to the sheet “Rules”
  • Reset: Disable the automation and remove your settings
  • Version: Check project versions

GoogleAppsScript Playlist (Follow My Channel for New Projects)

Links

Hire me on Upwork (work with me) 

Donate (PayPal)

YouTube (@ashtonfei) 

YouTube (@ashtontheroad) 

Github (@ashtonfei) 

Twitter (@ashton_fei) 

Instagram (@ashton.fei) 

OneScript (my website)

Comments