Query Google Sheet
Find and retrieve specific information from a Google Sheet
First, verify required connections are established.
- If user provided a spreadsheet URL/ID: only google_sheets is needed
- If user described the spreadsheet by name: both google_drive AND google_sheets are needed
Check connections and use connect_account to establish any missing ones before proceeding.
Understand what the user is looking for:
- What specific data do they want? (a link, a value, a row, contact info, etc.)
- Did they name a specific spreadsheet or describe what it contains?
- What keywords might identify the relevant row?
If user provided a spreadsheet URL or ID:
Extract the spreadsheet ID (the long string in URLs like:
https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit)
and skip to reading the sheet.
If user described the spreadsheet by name or content:
Run Find Files in Drive (from dependency) with:
- Search terms from their description
- mimeType: "application/vnd.google-apps.spreadsheet"
This will find matching spreadsheets and write results toDrive Search Results.
If search results are available, review the matching spreadsheets.
Single clear match: Proceed with that spreadsheet's ID.
Multiple matches: Look at names and modification dates to identify the best match.
If genuinely ambiguous, ask the user: "I found [X] and [Y]. Which one?"
No matches: Tell the user no matching spreadsheets were found and ask for the URL.
Once you have the spreadsheet ID, run Read Google Sheet with:
- arg1: The spreadsheet ID
- arg2: The output path from
Sheet Data
- arg3: Empty string to read all sheets
Search the sheet data for the user's requested information. Reference the
"Sheet Data Structure" section in Query Interpretation Guide for the JSON
format and detailed extraction guidance.
Use flexible matching for user search terms against cell values.
Extract hyperlinks from cells where the hyperlink field is not null.
Present findings with source attribution:
- The value or hyperlink requested
- Spreadsheet name, sheet tab, and row number
- Example: "Found in 'Office Furniture Order' → 'Furniture Sourcing' sheet, row 47"
If no match found, tell user what you searched and offer to show available data.
To run this task you must have the following required information:
> What information to find (description of the data, row, or link needed).
If the user specified a spreadsheet name, URL, or ID, include it.
If you don't have all of this information, exit here and respond asking for any extra information you require, and instructions to run this task again with ALL required information.
---
You MUST use a todo list to complete these steps in order. Never move on to one step if you haven't completed the previous step. If you have multiple CONSECUTIVE read steps in a row, read them all at once (in parallel). Otherwise, do not read a file until you reach that step.
Add all steps to your todo list now and begin executing.
## Steps
1. **First, verify required connections are established.**
- If user provided a spreadsheet URL/ID: only google_sheets is needed
- If user described the spreadsheet by name: both google_drive AND google_sheets are needed
Check connections and use connect_account to establish any missing ones before proceeding.
2. [Read Google Sheets API Guide]: Read the documentation in: `skills/sauna/[skill_id]/references/sheets.google.guide.md`
3. [Read Query Interpretation Guide]: Read the documentation in: `skills/sauna/[skill_id]/references/sheets.query.interpret.md`
4. Understand what the user is looking for:
- What specific data do they want? (a link, a value, a row, contact info, etc.)
- Did they name a specific spreadsheet or describe what it contains?
- What keywords might identify the relevant row?
**If user provided a spreadsheet URL or ID:**
Extract the spreadsheet ID (the long string in URLs like:
https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit)
and skip to reading the sheet.
**If user described the spreadsheet by name or content:**
Run `skills/sauna/[skill_id]/references/recipes/drive.files.find.md` (from dependency) with:
- Search terms from their description
- mimeType: "application/vnd.google-apps.spreadsheet"
This will find matching spreadsheets and write results to `session/drive_results.json`.
5. [Read Drive Search Results]: Read the file at `session/drive_results.json` into context
6. If search results are available, review the matching spreadsheets.
**Single clear match:** Proceed with that spreadsheet's ID.
**Multiple matches:** Look at names and modification dates to identify the best match.
If genuinely ambiguous, ask the user: "I found [X] and [Y]. Which one?"
**No matches:** Tell the user no matching spreadsheets were found and ask for the URL.
Once you have the spreadsheet ID, run `skills/sauna/[skill_id]/scripts/sheets.google.read.js` with:
- arg1: The spreadsheet ID
- arg2: The output path from `session/sheet_data.json`
- arg3: Empty string to read all sheets
7. [Read Sheet Data]: Read the file at `session/sheet_data.json` into context
8. Search the sheet data for the user's requested information. Reference the
"Sheet Data Structure" section in `skills/sauna/[skill_id]/references/sheets.query.interpret.md` for the JSON
format and detailed extraction guidance.
Use flexible matching for user search terms against cell values.
Extract hyperlinks from cells where the `hyperlink` field is not null.
Present findings with source attribution:
- The value or hyperlink requested
- Spreadsheet name, sheet tab, and row number
- Example: "Found in 'Office Furniture Order' → 'Furniture Sourcing' sheet, row 47"
If no match found, tell user what you searched and offer to show available data.