slice icon Context Slice

Query Interpretation

Understanding User Intent

When users ask for information from Google Sheets, decompose their request:

Component Question to Ask Example
Target What specific data do they want? "the link", "the price", "vendor contact"
Context What describes where to find it? "furniture order", "standing desks", "Q3 budget"
Sheet hint Did they name a specific spreadsheet? "in the office furniture sheet"

Query Decomposition Examples

"Find the link to the standing desks we ordered"

  • Target: hyperlink
  • Context: "standing desks", "ordered"
  • Sheet hint: likely an order/purchasing spreadsheet
  • Search strategy: Find sheets about furniture/orders → scan for "standing desk" rows → extract hyperlinks

"What's in our office furniture spreadsheet?"

  • Target: overview/summary of contents
  • Context: office furniture
  • Sheet hint: explicit - "office furniture spreadsheet"
  • Search strategy: Find sheet by name → summarize sheets and key data

"Get me the vendor contact from the Q3 budget"

  • Target: contact information (likely text, maybe email/phone)
  • Context: vendor, Q3
  • Sheet hint: explicit - "Q3 budget"
  • Search strategy: Find "Q3 budget" sheet → look for vendor-related rows → extract contact info

Search Strategy

When to Search Drive

Search for spreadsheets when the user:

  • Describes the sheet by content ("the furniture order", "my expenses")
  • Uses vague references ("that spreadsheet with the vendors")
  • Asks to find something without specifying where

When to Read Directly

Skip the search when:

  • User provides a spreadsheet URL
  • User provides a spreadsheet ID
  • Previous step already identified the sheet

Handling Multiple Matches

If searching returns multiple spreadsheets that could match:

  1. Check names for best match - "Office Furniture Order" beats "Q3 Expenses" for a furniture query
  2. Consider recency - More recently modified often more relevant
  3. Ask if ambiguous - "I found 'Office Furniture Order' and 'Vendor Contacts'. Which one has the standing desk info?"

Don't silently pick one if there's genuine ambiguity.

Finding Rows in Sheet Data

Semantic Matching

User queries rarely match cell text exactly. Apply flexible matching:

User says Might match
"standing desks" "Adjustable Standing Desk", "Stand-up Workstation", "Jarvis Desk"
"the vendor" "Supplier", "Vendor Name", "Company"
"price" "Cost", "Amount", "Total", "$"

Column Context

Headers provide context for what values mean:

| Item          | Vendor      | Link                    |
| Standing Desk | Fully       | https://fully.com/order |

If user asks for "the vendor for standing desks":

  1. Find row where Item contains "standing desk"
  2. Return value from Vendor column

Multiple Hyperlinks

A row might have several hyperlinks:

  • Product page
  • Vendor website
  • Invoice/order confirmation
  • Internal docs link

If multiple hyperlinks exist and user didn't specify, list options:
"Found 3 links in that row: the product page, vendor site, and invoice. Which do you need?"

Response Formatting

Always include source attribution:

Good:

Found it! The standing desks link: Fully Jarvis
From "Office Furniture Order" → "Furniture Sourcing" sheet, row 47

Bad:

Here's the link: https://fully.com/order/12345

Attribution helps users:

  • Verify the source
  • Navigate to the sheet themselves
  • Understand where their data lives

Sheet Data Structure

The fetched data from codeRead Google Sheet has this structure:

{
  "title": "Spreadsheet Name",
  "sheets": [{
    "name": "Sheet1",
    "rows": [{
      "row": 1,
      "cells": [{
        "column": 0,
        "value": "Cell text",
        "hyperlink": "https://...",
        "hyperlinkText": "Link display text"
      }]
    }]
  }]
}

Finding relevant rows:

  • Match user's search terms against cell values (flexible matching—"standing desks" matches "Standing Desk - Jarvis")
  • Use header row context to understand what columns mean
  • Check multiple sheets if the data might be in a different tab

Extracting hyperlinks:

  • Look for cells where hyperlink is not null
  • If multiple hyperlinks exist in a row, note all of them

If no match found:
Tell user what you searched and ask if they can provide more specific details.
Offer to show what data IS in the sheet so they can refine their search.