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

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

Описание и применение

В этом руководстве описывается, как настроить чат-бота n8n для работы с Google Sheets, чтобы получать корректные ответы и избегать ошибок в вычислениях.

Задача

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