Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

n8n: Talk to your Google Sheets with an AI Agent (and why it sometimes gets the math wrong)

说明与用途

本指南说明了如何设置 n8n 聊天代理与 Google 表格交互,确保答案准确并避免计算错误。

问题

The AI Agent in n8n can confidently provide incorrect sums when asked to calculate totals from Google Sheets.

结果

The workflow enables accurate, transparent interaction with Google Sheets via an AI Agent, reducing math errors by leveraging spreadsheet formulas and clear prompts.

工作流

  • Prepare a clean Google Sheet with a single header row and one record per row.
  • Connect the Google Sheets tool node in n8n, select credentials, choose the document and sheet, and set operation to read rows.
  • Provide a tool description such as {"name":"client_invoices","description":"Returns every row of the client invoice sheet. Columns: Client, Industry, Invoice, Status, Due."}.
  • Add a short system prompt: "You answer questions about the client invoice sheet. Always read the sheet before answering. If the answer needs a calculation, show the rows you used. If you are not sure, say so instead of guessing."
  • Ask lookup questions first (e.g., "Which clients are overdue?").
  • When asking for totals, request the rows used or use a spreadsheet formula (e.g., a Summary column or pivot tab) to perform the calculation outside the model.
  • Filter rows before returning them if the sheet is long to avoid exceeding the model’s context limit.
  • Verify the agent’s answer against the sheet’s calculated value before using it in reports or emails.

证据

The agent reads your question and decides what to do.

来源

Agents do much better with a boring, clean table. Use one header row, one record per row, and no merged cells.

来源

The reason is that a language model predicts text. It is not a calculator.

来源

Make it show its work. Asking for the rows it used lets you spot a missing record in seconds.

来源

Do the math outside the model. Add a Summary column or a pivot tab in the sheet itself and have the agent read that figure.

来源

  • 记录日期: 2026-10-11T13:40:56.883Z