n8n Basics: Splits and Aggregates, No Loop Required
One nice feature of n8n that I didn't quite understand at first is item splitting.
I kept trying to add a Loop flow where I didn't actually need one because n8n would automatically repeat for each item after the Split.
But if you need to stop repeating every node for every item, then you have to bring the items back together.
In the attached image, I needed to grab image Ids from different sources and put them all in one list.
The first Split separated all the image columns, but some of those columns had more than one image so the second split ran 5 times for each column and found 4 more items to split out.
No need to loop through the columns, n8n handled the items for me.
After getting all the images, I didn't want to call the API to download the images 9 different times, instead I aggregated all the image Ids back into one item, and sent that list to the API instead.
So Items in n8n can be really powerful if planned for and handled correctly, making for a cleaner workflow without out the crazy looking mess of loops everywhere.
Just have to know when to Aggregate (or Filter, or Merge, or Switch...) to get back to one item and one execution per node.
Been spending a good amount of time splitting items out and aggregating them back so thought this might be helpful.
Let me know if you have any questions.
More n8n basics soon!
1
6 comments
Jay Peters
5
n8n Basics: Splits and Aggregates, No Loop Required
Learn Automation and AI
skool.com/learn-automation-ai
Learn, build, and ship AI Automations in days, not months. Templates, live help, community.
Leaderboard (30-day)
Powered by