AI Agent won't update the correct row using google sheet subnode

Describe the problem/error/question

I have manual start, get rows in google sheet, set node to set the vendor and row number (thought it might fix, doesn’t), then goes to an AI Agent tools node. The goal is to have it, for each vendor in the sheet, do a search and answer a question, then update the sheet in that vendor’s row. I’ve tried everything, but it only updates in row 2. I have it set to match on row number (I’ve also tried matching on vendor)

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.76.3
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): cloud
  • Operating system: macOS
1 Like

Hi @Jeff_Morrell,

Welcome to the community :tada:

The issue here is that right now it’s not possible to refer to inputs from previous nodes as expressions when there are multiple items in the input of the AI Agent. If you do, it will always refer to the first item in the Agent input but we’re working on fixing this. In the meantime, you can just use (($fromAI()}} to refer to variables:

Here’s a workflow example:

You can also try using the Google Sheets node after the AI Agent instead of using the Google Sheets tool like so

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.