Merge Data From Multiple Loop Executions - n8n Workflow

Learn how to build an advanced n8n workflow using custom scripting and iteration control. This n8n node combination merges data from multiple RSS feed reads into one output.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Users looking to aggregate data efficiently from multiple external sources within a single n8n execution.
Developers needing advanced examples of custom Javascript logic inside an n8n node.
Anyone interested in mastering complex iteration, looping, and data merging techniques in n8n.
Automation specialists who want to create highly efficient, customized n8n templates.

Overview

While n8n is powerful for parallel processing, sometimes you need precise control over sequential loops and aggregation. This specific n8n workflow demonstrates a technique to fetch content from multiple URLs (specifically two RSS feeds in this example) sequentially. The true innovation lies in the use of the IF n8n node combined with the SplitInBatches context to create a controlled loop, ensuring every feed is read. Crucially, a final custom Function n8n node then retrieves and combines the data from all previous loop executions, delivering a consolidated result. This pattern is essential for creating robust data aggregation n8n templates.

How it Works

The n8n workflow begins with the On clicking 'execute' n8n trigger.


  1. Initialize URLs: The first Function n8n node defines the input, creating separate items for each RSS feed URL (Medium and Dev.to) related to n8n content.

  2. Sequential Processing: The SplitInBatches n8n node ensures that the flow processes only one URL item at a time.

  3. Data Fetch: The RSS Feed Read n8n node executes using the current batch's URL.

  4. Loop Control: The IF n8n node checks the SplitInBatches context.

If items remain (noItemsLeft is false), the flow loops back to SplitInBatches via Path 1 to process the next URL.
If all items have been processed (noItemsLeft is true), the flow proceeds to the final aggregation step (Merge Data) via Path 0.

  1. Final Aggregation: The Merge Data custom Function n8n node executes only once all loops are complete. It uses a custom script iterating through previous executions of the RSS Feed Read n8n node using the $items() helper function, collecting all fetched data into a single JSON object. This completes the entire n8n workflow.

Installation Guide

To use this advanced n8n workflow, follow these steps:


  1. Import the JSON: Copy the provided n8n workflow JSON code. In your n8n instance, go to the Workflows section, click the '+' button, and select "Import from JSON."

  2. Setup Credentials: This specific n8n workflow uses the built-in RSS Feed Read n8n node, which typically does not require external credentials. Ensure your n8n instance can reach external URLs.

  3. Review the Code: Open the Merge Data n8n node to understand the specific JavaScript logic being used for aggregation. Modify the feed URLs in the initial Function n8n node if you want to track different sources. This n8n template is designed for easy modification.

  4. Execution: Click the "Execute Workflow" button or use the On clicking 'execute' n8n trigger to test the data merging functionality. This advanced n8n template is ready to run out of the box.

Node Details

This custom n8n workflow leverages several key n8n node types:

On clicking 'execute' (Manual Trigger): The standard entry point. This n8n trigger initiates the entire process manually for testing and execution.
Function (URL Initialization): Generates two items, each defining an RSS feed URL. This feeds the initial list of tasks to the SplitInBatches n8n node.
SplitInBatches: Crucial for controlling the iteration. It sends items one by one to the downstream n8n node (RSS Feed Read). Key Configuration: Batch Size is set to 1.
RSS Feed Read: The core action n8n node, dynamically configured to read the URL passed in the input (={{$json["url"]}}).
IF: The flow control n8n node that manages the loop. It checks if the SplitInBatches n8n node has completed its job by evaluating the $node["SplitInBatches"].context["noItemsLeft"] expression. If incomplete, it loops back, ensuring the n8n workflow processes all items.
Merge Data (Function): This complex custom n8n node contains the aggregation script. It uses Javascript’s $items("RSS Feed Read", 0, counter) to access the output of the RSS Feed Read n8n node from every iteration, consolidating all results into a single item for final output. This powerful technique is what distinguishes this n8n template.

Related n8n Workflows

Free

Nodes: 5 Nodes
Updated: December 26 2025
View all
Created by
ghagrawal17
ghagrawal17

Featured*