Advanced n8n: Sub-agents, Iterators, and Daily Reporting (Part 4)
· Manuel · 30 min read · Automation
If Part 1 was learning to walk, and Parts 2 & 3 were running... Part 4 is flying a fighter jet.
We have covered linear workflows (Trigger -> Action). But real business data is messy.
This is where the "Low Code" power of n8n truly separates itself from the "No Code" toys. Today we master Loops, Aggregation, and Sub-Workflows.
This is how we automate entire departments, not just tasks.
Related Reading
Concept 1: The Loop (Split in Batches)
Connect a Google Sheet node that returns 1000 rows to a HTTP Request node. Zapier: Crashes or costs you $50 in tasks. n8n: Automatically loops.
But wait. What if the API you are calling has a rate limit? "Max 60 requests per minute." If n8n blasts 1000 requests in 1 second, you get banned.
The Solution: Split in Batches 1. Add a Split in Batches node. 2. Batch Size: \
Concept 2: Aggregation (The Item Lists Node)
Common Problem: You have 5 sales today. You want to send ONE email to the CEO with a summary table. Default n8n behavior: It sends 5 separate emails. (Annoying).
The Solution: Aggregate We need to turn 5 items back into 1 item. 1. Add Item Lists node. 2. Operation: "Aggregate". 3. Field to Aggregate: \
Concept 3: Sub-Workflows (Modular Architecture)
As a developer, you know the DRY principle: Don't Repeat Yourself. If you have a complex logic block (e.g., "Format Phone Number and Enlight with Clearbit"), you don't want to rebuild that in every single automation.
Build a Micro-Service (Sub-Workflow) 1. Create a new workflow: "Utility - Lead Enrichment". 2. Trigger: Execute Workflow Trigger. 3. Add your Clearbit/Formatting logic. 4. End: Return Data node.
Call it from Main Workflow 1. In your "Lead Gen" workflow, add an Execute Workflow node. 2. Select "Utility - Lead Enrichment".
Now, if you need to update your enrichment logic (e.g., switch from Clearbit to Apollo), you change it in one place, and all 50 of your automations are instantly updated. This is how you scale.
The Project: Daily Sales Dashboard
We are going to build a system that runs every night at 11pm. 1. Trigger: Schedule (Every Day at 23:00). 2. Source: Stripe (Get all payments from 'Today'). 3. Loop: For each payment, categorize it (New vs. Recurring). 4. Aggregate: Create two lists (New List, Recurring List). 5. Generate Report: Create an HTML email with two tables and a "Grand Total". 6. Send: Gmail to Executives.
This gives you a heartbeat of your business every single morning, automatically.