ChatGPT Integrated with Google Sheets Using Google Apps Script: GAS100

Introduction

In this Google Apps Script project, I have created a chat app that is integrated with the ChatGPT API. The user interface for this chat app is provided by Google Sheets. Similar to the ChatGPT chat web app, you can directly submit your prompts from the Google Sheets interface. This project serves as a practical demonstration of how to integrate the ChatGPT API with Google Apps Script, which could be useful if you want to use the OpenAI API in your own projects.

YouTube

If you're a visual learner and prefer watching video instructions, I highly recommend checking out these videos.

Instructions (4 Steps)

To establish your own project, adhere to the following steps:

Step 1

Utilizing the provided link, you can create a duplicate of my project on your Google Drive.

Make a copy

Step 2

To fulfill the authorization requirement, navigate to the copied Google Sheets document and select any button located within the tab “Chat”.

* Check the authorization guide if unfamiliar with the process.

A Complete Guide to Authorize GAS Project

Step 3

From the custom menu "ChatGPT," click the "Set API Key" button to establish your unique API key. 

Step 4

Within the "Chat" tab, three functions are available to assist you in interacting with the ChatGPT API. These functions include:

  • Load - If you've had previous conversations, you can choose one from column B to either review or resume.
  • New - This script has the ability to remove all the existing messages in the current chat and initiate a brand new chat conversation.
  • Send - To obtain a new response, send prompts with messages from cell E2 and historical messages to ChatGPT.

Other Features

  • Within the "ChatGPT" custom menu, after setting up your API key, you have the option to remove it if needed.
  • To inspect the source code, you can access the App Scripts editor. To do this, navigate to the menu bar of your Google Sheets and select "Extensions" followed by "Apps Script."

GoogleAppsScript Playlist (Subscribe for New Projects)

Links

Hire me on Upwork  Donate (PayPal) YouTube Github Twitter / X Instagram 

Comments