How to add sheets multiple cell values one by one in Openai?

My current workflow is as follows.

Each row when added will have multiple columns. Suppose A2 to AU2.

How to add these cells one by one in openAI as prompts and output the result in different sheet at same location (row,column) ?

In above Example I want first to use “Hello” then “hi” and Finally “hi” as “Content” for “User Role”. The the output is added to another sheet at the same location.

Hi @Chirag_Nikose, welcome to the community :tada:

The problem here is that all of your fields (1, 2, 3, 4) are part of a single row. When reading a sheet, n8n treats each row as a single item.

So in order to run your logic (not just the OpenAI node, but any node) you’d need to add multiple fields to your OpenAI node and then reference your input data using expressions such as {{ $json["1"] }}, {{ $json["2"] }}, etc in each of the message fields.

The bigger problem will be the update. To update a specific row in a Google Sheet through n8n, the row needs a unique identifier. So my suggestion would be to add an ID column of some sort in addition to your existing columns 1, 2, 3 and 4. This would let you use the Update operation of the Google Sheets node.

1 Like

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