Custom action for Google Sheets

Hi,

I’m looking for any guide describing how to call Google Sheets from my GPT as an action and store there data.

2 Likes

Welcome to the forum.

Here’s an overview of the steps to call Google Sheets from your GPT model as a custom action and store data in it:

Set Up Google Sheets API:

  • Create a Google Cloud project.
  • Enable the Google Sheets API for your project.
  • Generate credentials in the form of a JSON file.

Authenticate Your GPT Model:

  • Load and use the credentials JSON file to authenticate your GPT model with the Google Sheets API.

Write Code to Interact with Google Sheets:

  • Develop code using a client library (e.g., Google API Client Library for Python) to interact with Google Sheets.
  • Implement functions to perform actions like creating, reading, updating, and deleting data in your Google Sheets.

Call Google Sheets from Your GPT Model:

  • Within your GPT model or application, invoke the code you’ve written to interact with Google Sheets.
  • Use these calls to store and retrieve data as needed.

Remember to consider security and error handling in your implementation and refer to the detailed documentation provided by Google for the Google Sheets API and your chosen client library for specific instructions.

1 Like

Depending on how complex your needs, you might also try directly using the sheets.googleapis.com from the Action without writing any code and using the GPT as a natural language interface to the API

You might find it an interesting (and possibly frustrating) experience.

You may need to pare down the schema / fix it up for the GPT to validate it

EDIT: Caveat I have only tried google apis with api token so far, not with Oauth, so that might change things.

1 Like

i keep running into authentication errors. I would my customgpt ask its external users / potential clients some questions and then for the information to be stored directly into a googlesheets document I own, using the googlesheetapi directly. Even when I make my document publically available I keep running into authentications errors. As I don’t want to the user to identify himself, but somehow code the authentication directly into the customgpt api (with proper restrictions on the google cloud side), I find few examples how to do that. I’ve tried creating a service account and and a apikey, but none of them seem to work.

1 Like

This GPT should do the job https://chat.openai.com/g/g-IC2jFLI8c-sheet
It interfaces through App script because GPT4 struggles interacting with the API directly. Also had to setup a whole OAuth screen on GCP for the access to the document

2 Likes

DISCLAIMER: I work at superface

Google sheets is a tricky API for LLMs. Our solution was to wrap it in a custom tools with a simpler interface for GPT to understand. You can test it at Connect GPTs to Google Sheets . It comes with solved OAuth for you and your GPT users.

3 Likes

When you say custom tools, you are referrring to "Superface
’ correct? If not what does that mean?

yea, but you can develop and host it on your own - create a dedicated endpoint that simplifies the google sheets api call…

I need direction in those steps. Usually when I ask I can never get a clear and direct answer. Where would I go to develop and host?

1 Like

Yeah! @PaulBellow, that is a great explanation, but like @Chowderr says, I feel like I’m missing a conceptual step.

When you say “develop and host” do you mean develop your website as an oAuth server so it can do this middle step?

Or is there something else that’s happening on Google Cloud that I’m missing?

1 Like

Sorry for the confusing. Some platforms you have to have a “server”, to do things for oAuth - I think I ran into it about two or three times so far. I found great companies though that take care of those aspects so it is not a concern anymore. i mainly try to understand as I want to build my own platform.