|
|
ADK with Google Sheets - Reading and Writing Data
Author: Venkata Sudhakar
Google Sheets is widely used in Indian businesses for inventory tracking, sales reporting, and budget management. An ADK agent connected to Sheets can read live data, perform analysis, and write results back - turning a static spreadsheet into a conversational reporting tool. ShopMax India uses this to let managers query the daily sales sheet in plain English and append summary rows automatically.
The Sheets API uses the spreadsheets scope. The agent tools use the spreadsheets.values.get method to read ranges and spreadsheets.values.append to write new rows. Service account credentials with editor access to the target spreadsheet are sufficient - no domain-wide delegation needed if the sheet is shared with the service account email.
The below example shows an ADK agent that reads sales data from a sheet and appends a daily summary row.
It gives the following output,
Read 18 sales rows from Sales!A1:E20.
Summary for 2026-04-06:
Total Revenue : Rs 4,12,850
Top Product : Samsung 55" QLED TV (Rs 98,400 across 6 units)
Store Count : 4 stores reported
Appended summary row to Sales sheet:
[2026-04-06, SUMMARY, Rs 4,12,850, Samsung 55" QLED TV, 18 transactions]
Updated range: Sales!A20
For automated daily reporting, deploy the agent as a Cloud Run job triggered by Cloud Scheduler at 11 PM IST. Use the Sheets API batchUpdate method to apply formatting (bold, colour) to summary rows. Chain this agent with the Gmail agent to email the summary to the regional manager every morning at 9 AM.
|
|