Master complex nested looping challenges in n8n by utilizing sub-workflows and the Execute Workflow n8n node. Download this reliable n8n template for modular data processing logic.
Download this n8n workflow template and start using it instantly.
Automation specialists struggling to implement reliable nested loops in a single n8n workflow.
Developers requiring modular data processing structures.
Users looking for advanced n8n templates focusing on flow control.
Anyone interested in best practices for using the Execute Workflow n8n node.
While a powerful platform, n8n sometimes requires creative solutions for complex flow control patterns, such as nested loops (iterating over one list for every item in another list).
This robust n8n workflow template provides the definitive solution by separating the nested logic into two distinct components: a main workflow and a reusable sub-workflow. The main workflow uses the Split In Batches n8n node to iterate over the 'outer' list (Colors), and for each item, it calls a dedicated sub-workflow using the Execute Sub-workflow n8n node.
The sub-workflow receives the outer item as a parameter, executes its own inner loop (Integers), and combines the results. This approach ensures cleaner execution, prevents data mixing issues common in single-workflow looping structures, and showcases the power of the Execute Workflow n8n node for modular design. This n8n solution is essential for handling complex combinatorial data tasks.
This automation is comprised of a main execution flow and a secondary sub-workflow logic, connected via the Execute Workflow n8n node.
When clicking ‘Execute workflow’.Colors Code n8n node generates the primary list (yellow, blue, green).Loop Over Colors Split In Batches n8n node begins iterating through the generated color list, processing one color per batch.Execute Sub-workflow n8n node is called. It passes the current color value as an input parameter to the sub-workflow.When Executed by Another Workflow n8n trigger, accepting the color parameter from the main n8n workflow.Integers Code n8n node generates the secondary list (1, 2, 3).Loop Over Integers Split In Batches n8n node iterates through the integers.Edit Fields Set n8n node performs the core processing. It combines the outer loop's color (received via the initial n8n trigger) with the current inner loop's number, producing a final result like 'yellow - 1'.This structure ensures that for every item in the outer list, the entire inner n8n workflow sequence runs, reliably generating all required combinations.
To deploy this powerful n8n workflow and its associated sub-workflow, follow these steps:
When Executed by Another Workflow n8n node) must be moved to a separate, new n8n workflow canvas. Save this new sub-workflow.Execute Sub-workflow n8n node.Sub-workflow field to select the exact name of the new workflow you created in Step 2. Ensure the input parameter color is correctly mapped as ={{ $json.color }}. When clicking ‘Execute workflow’ (Manual Trigger n8n trigger): Initiates the primary n8n workflow flow on demand.
Colors (Code n8n node): Generates the initial array data for the outer loop (the colors list). This demonstrates data preparation within an n8n node.
Loop Over Colors (Split In Batches n8n node): The primary flow control n8n node that handles batching the color list, ensuring the next step runs once per color item.
Execute Sub-workflow (Execute Workflow n8n node): The crucial connection node. For every item in the outer loop, it calls the separate sub-workflow. Key configuration: Passes color input to the downstream n8n workflow.
When Executed by Another Workflow (Execute Workflow Trigger n8n trigger): The entry point for the sub-workflow. It is configured to accept the color input passed by the main n8n workflow.
Integers (Code n8n node): Generates the array data for the inner loop (the numbers list) within the sub-workflow.
Loop Over Integers (Split In Batches n8n node): Controls the inner loop iteration, processing the number list one item at a time.
Edit Fields (Set n8n node): The final processing step. Uses n8n expressions to combine the incoming color data (from the n8n trigger) with the current number data (={{ $('When Executed by Another Workflow').item.json.color }} - {{ $('Loop Over Integers').item.json.number }}) into a combined result field.
Use this comprehensive n8n workflow to build a dynamic AI voice bot integrated with Twilio, OpenAI GPT-4o, and ElevenLabs for real-time customer interaction and automated data logging in Google Sheets.

Leverage this advanced n8n workflow to build AI agents with multi-step reasoning using GPT-4. Learn how to customize reusable 'thinking' tools within your n8n automation.

Automate multi-speaker podcast creation using this powerful n8n workflow. Pull dialogue from Google Sheets, generate expressive audio via ElevenLabs v3, and save the final audio file to Google Drive.

Use this powerful n8n workflow to automatically create Notion tasks from incoming Telegram messages (text or voice) using GPT-3.5 for intelligent data extraction and scheduling. Deploy this n8n template now.








































