Hello All,
I am brand new to n8n. Have been using Make.com and Pabbly.com for our automations. And starting to look at n8n now. I think I got most of the code working, but I’m have a challenge with the Loop over items.
This is our process in Make that we are re-creating in n8n.
Make has a function called an Iterator (Iterator is a special type of module that converts an array into a series of bundles. Each array item will output as a separate bundle).
=> https://www.make.com/en/help/modules/iterator
I’m sure it something simple but I can’t seem to see how to resolve it.
I have 2 items going into the Loop Over Items and I’m expecting to write 2 records to Airtable. But I’m only getting 1 record written.
Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.
```
<your workflow>
```
That implies to any JSON output you would like to share with us.
It doesn’t look like you need to use Loop in your n8n workflow. Without the Loop each node works on each item (which corresponds to a bundle in Make) separately and automatically, no need for an explicit iterator.
Using Loop in your case doesn’t really play any role unless you want to introduce a delay between the first and subsequent API calls to the OpenRouter. The Loop is typically used for that purpose (delays) to ensure the threshold on the API is not breached. Its purpose is somewhat different from Make’s iterator as n8n does iteration automatically by processing each item by each node. That is, each node works on each item before passing over the outcome of all the items processed to the next node.
Though I still wonder what “Code_Stringify_Ideas” node does. Perhaps you need to aggregate your items first to use the aggregated result in HTTP Request node (make one item our of two)? It important to node that in order for Loop to complete (iterate over each item), the last node in the Loop has to return something back to the Loop node with each iteration. Say, if “Airtable_All ideas” or any node in the loop does not return a value (or returns an empty value) the Loop will terminate prematurely (without an indication of a failure). Yet again, I believe you can get by without the Loop node.
I have tried to load my workflow into this message thread but I keep getting a 403.
Any idea how to get my code uploaded? Did a video of the problem below.
My challenge is that one record coming in from Airtable. Has 2 fields that could have 1-n (in this test 2 records) pieces of information that I need to loop through and send to OpenRouter.
These are in the Code_PackagePromptTempalte (Different prompts to send to OpenRouter)
Field 1: promptUsed
Field 2: packagePromptTemplate
The Code_Stringify_Ideas was put in place as I keep getting “JSON not valid” when sending to OpenRouter.
So maybe I’m approaching this wrong for the way that n8n works. I’ll look at aggregate as you suggested or maybe an IF loop.