How To Use AI To Search Google Sheet For Data To Answer Clients
This guide walks you through creating a read-only API for a Google Sheet and connecting it to an AI agent as a custom tool.
Google Sheet Integration Tutorial
Part 1: Stand Up a Read-Only Google Sheet API
1. Prepare Your Sheet
- Create a new Google Sheet or open an existing one
- Name the specific tab you want to use (e.g., Products, Services, Inventory)
- In the first row, enter your column headers. Make sure they are unique and have no spaces or special characters:
- \id | name | price | description | stock_quantity | permalink\
- Fill in the subsequent rows (from row 2 downwards) with your data
2. Write & Deploy an Apps Script Web App
- In your Google Sheet, navigate to Extensions → Apps Script
- A new script editor will open. Delete any boilerplate code
- Paste the following code into the editor:
3. Set the API Secret
- In the Apps Script editor, click Project Settings (gear icon)
- Scroll down to Script Properties and click Add script property
- Property: API_SECRET
- Value: Enter a strong, random string (DO NOT INCLUDE ANY SYMBOLS, Alphabet & Numbers Only)
- Save the script properties
4. Deploy the Web App
- Click Deploy → New deployment
- Select Web app as the type
- Set Execute as: Me
- Set Who has access: Anyone
- Click Deploy and authorize the app
- Copy the Web App URL - this is your API endpoint
Part 2: Configure the Custom Tool in ABC Sales AI
- In your ABC Sales AI dashboard, go to AI Agents → AI Tools
- Click Add Tool and select Custom Tool
- Configure the tool:
- Tool Name: search_sheet
- Description: Searches for products/data and returns matching results
- Method: GET
- URL: Paste your Apps Script URL with \?secret=YOUR_API_SECRET&search=\
- Add the parameter:
- Name: search
- Type: String
- Location: Query
- Required: Yes
- Save the tool and add it to your AI Agent