How to make the chatgpt assistant query a Google Sheets spreadsheet and return to the user whether that item exists or not?

What are you trying to achieve?

simulating a trade: I want to ask the AI ​​agent if there is x item and he consults the spreadsheet, returning the product and the price.

Steps taken so far

I simulated a question via webhook, and the GPT module answers the question, but it doesn’t query the spreadsheet. I’ve tried adding the spreadsheet before the GPT module, but to no avail.

Hey Pablo!

The issue is that you need to set up GPT Function Calling (also called Tools/Actions in ChatGPT). Simply putting Google Sheets before the GPT module won’t work because GPT doesn’t automatically know to query it.

Here’s the correct workflow:

Scenario Structure:

Webhook → GPT Assistant (with Functions) → Router → Google Sheets Search → GPT Assistant (return results)

Step-by-Step Setup:

1. Create your Google Sheets Search function: First, set up a route that searches your spreadsheet:

  • Module: Google Sheets > Search Rows
  • Search in: Your product spreadsheet
  • Filter: Product Name contains the search term

2. Configure GPT with Function Calling: In your ChatGPT module, enable “Functions” and define your tool:

{
  "name": "search_product",
  "description": "Search for a product in the inventory spreadsheet and return the product name and price",
  "parameters": {
    "type": "object",
    "properties": {
      "product_name": {
        "type": "string",
        "description": "The name of the product to search for"
      }
    },
    "required": ["product_name"]
  }
}

3. Add a Router after GPT:

  • Route 1: If GPT calls the function (check if function_call exists)
  • Route 2: If GPT returns a normal response

4. On Route 1 (Function Call):

  • Google Sheets > Search Rows: Use the parameter from GPT’s function call
  • Map: {{function_call.arguments.product_name}}
  • Router/Filter: Check if results exist
    • If found: Format the response with product details
    • If not found: Return “Product not found”
  • ChatGPT > Create a Completion: Send the results back to GPT with the function response

5. Final response: Return GPT’s final answer to the webhook response

Simplified Alternative (If you don’t need conversational AI):

If you just need a simple lookup without conversation:

Webhook → Google Sheets Search Rows → Router → Webhook Response
  • Router Route 1 (if found): Return “Product: [name], Price: [price]”
  • Router Route 2 (if not found): Return “Product not found”

Example Google Sheets Setup: Make sure your spreadsheet has columns like:

  • Column A: Product Name
  • Column B: Price
  • Use “Search Rows” with filter: Product Name = {{webhook.query}}

Which approach do you prefer? The AI agent with function calling gives you natural language responses, while the direct search is simpler and uses fewer operations.

Sam @ Flow Digital