Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 20

Data Workflow Automation

Recommended resources

Introduction

Welcome to the final lesson of our module on Control Flow and Branching. Over the past few lessons, you've mastered the individual components of complex workflow logic: creating conditional paths with the IF and Switch nodes, recombining them with the Merge node, and iterating through data with the Loop Over Items node. Now, it's time to put all those pieces together.

Today's lesson is a capstone project for this module. You will build a complete workflow from scratch that integrates these concepts to solve a practical problem. We will construct a workflow that takes a predefined list of development tasks, filters out low-priority items, branches the remaining tasks based on their type, applies different processing steps to each branch, and finally merges them back into a single, organized list. This "Filter, Branch, Process, Merge" pattern is a fundamental building block for the sophisticated CI/CD automations you aim to create.


The "Filter, Branch, Process, Merge" Pattern

This pattern is ubiquitous in automation. Before performing resource-intensive actions, you want to ensure you're only working on relevant data. A great pro-tip is to filter your data as early as possible in the workflow. This makes your workflow more efficient and easier to debug.

13 Essential n8n Workflow Concepts Every Beginner Should Master (2026) | GrowwStacks Blog

The article from Growwstacks.com explains the value of filtering and introduces the dedicated Filter node.

In the article, find the section "Limiting and Filtering Items" and read the two paragraphs under it, starting from the main text. The key takeaway is the advice to "filter early" to avoid processing unnecessary data.

After filtering, you often need to handle different types of data in different ways. This is where branching with an IF or Switch node comes in. Once the separate processing is complete, a Merge node reunites the data streams.

The sponsorship inquiry workflow you saw in a previous resource is a perfect real-world demonstration of this entire pattern.

Master 80% of n8n in 36 Minutes

In the video "Master 80% of n8n in 36 Minutes," the presenter builds a workflow that perfectly illustrates this pattern. Let's review it as a case study.

Watch the segment from building the workflow. Observe how the workflow uses: A predefined data set (from the form submission). Branching with a Switch node based on the submission's budget. Parallel processing by sending different emails and logging different actions on each branch. Although it doesn't explicitly use a Filter or Merge node, the Switch node implicitly filters the data into paths, and the Google Sheet acts as the final merged destination.


Hands-On: Building an Issue Triage Workflow

Let's build a workflow that automates the initial triage of engineering tasks.

Scenario: We have a list of new issues. Each issue has a title, a type (bug or feature), and a priority (high, medium, or low).
Goal:

  1. Filter out all low priority issues.
  2. Route bug reports and feature requests down separate paths.
  3. Assign a triage_status to each type: "Awaiting Fix" for bugs and "Backlog Review" for features.
  4. Merge the processed issues back into a single list for final review.

Step 1: Create the Mock Data

First, create a new, blank workflow.

  1. Your workflow starts with the default Manual trigger (the "Start" node).
  2. Add a Set node and name it Create Mock Issues.
  3. Ensure Mode is set to Append.
  4. Click Add Value and select Expression.
  5. In the Name field, type issues.
  6. In the Value field, paste the following JSON. This creates a single item containing an array of our issues.
[
  { "title": "UI button misaligned", "type": "bug", "priority": "high" },
  { "title": "API returns 500 error", "type": "bug", "priority": "high" },
  { "title": "Add dark mode", "type": "feature", "priority": "medium" },
  { "title": "Fix typo in docs", "type": "bug", "priority": "low" },
  { "title": "Integrate with Slack", "type": "feature", "priority": "high" },
  { "title": "Update footer copyright year", "type": "feature", "priority": "low" }
]

Execute this node. You'll see one item in the output, with an issues field containing an array of 6 objects.

Step 2: Split the Array into Items

Most n8n nodes operate on a list of items, not a single item containing a list. We need to "unpack" our array.

  1. Add a Code node. It's the most straightforward way to do this.
  2. Change the Mode to Run Once for All Items.
  3. Make sure the language is Python.
  4. Paste the following code. This takes the issues array from the input and returns each element as a separate n8n item.



# The input is a list with one item
# That item has a field 'issues' which is an array of objects
input_data = items[0].json['issues']




# Return the array of objects. n8n will turn each object into a separate item.
return input_data

Execute this node. The output should now be 6 distinct items, one for each issue.

Step 3: Filter Low-Priority Issues

Now we apply our "filter early" principle.

  1. Add a Filter node after the Code node. Name it Filter Low Priority.
  2. Click Add Condition.
  3. In the first value box, use an expression to get the priority: {{ $json.priority }}.
  4. Set the operator to Not Equal.
  5. In the second value box, type low.

Execute the workflow from the start. After the Filter node, you should see only 4 items remaining—the two low priority issues have been removed.

Step 4: Branch by Issue Type

Next, we'll use a Switch node to create different paths for bugs and features. The SW Automation video provides an excellent deep-dive on the Switch node's configuration.

How to Use the IF and SWITCH Nodes in n8n (Complete Guide)

The video "How to Use the IF and SWITCH Nodes in n8n" explains why and how to use the Switch node for multi-conditional routing.

Watch the conceptual explanation from the introduction, and then see how it's configured in the segment from setting up routes. We will use this exact method.

  1. Add a Switch node after the Filter node.
  2. For the Value to Switch On, use the expression {{ $json.type }}.
  3. Change the Data Type to String.
  4. Under Routing Rules, click Add Routing Rule.
  5. Set the first rule's Value to bug.
  6. Set the second rule's Value to feature.
  7. This will create three outputs on the node: bug, feature, and default.

Step 5: Process Each Branch

Now we'll add a Set node to each branch to perform the path-specific processing.

  1. From the bug output of the Switch node, add a Set node. Name it Process Bugs.
  2. Set Mode to Append.
  3. Add a field named triage_status with the string value Awaiting Fix.
  4. From the feature output of the Switch node, add another Set node. Name it Process Features.
  5. Set Mode to Append.
  6. Add a field named triage_status with the string value Backlog Review.

Step 6: Merge the Branches

Finally, let's bring our processed data streams back together.

  1. Add a Merge node to the canvas.
  2. Connect the output of the Process Bugs node to the Input 1 of the Merge node.
  3. Connect the output of the Process Features node to the Input 2 of the Merge node.
  4. Open the Merge node. The default Mode is Append, which is what we want. It simply stacks the items from all inputs into a single output list.

Your final workflow should look something like this:
Start -> Set (Mock Issues) -> Code (Split) -> Filter -> Switch -> [Set (Bugs), Set (Features)] -> Merge.

This is a simplified example of a workflow that branches data from a start node into two separate processing paths (Set and Python) which then converge into a single Code node, illustrating the core Branch -> Process -> Merge pattern.

Now, execute the entire workflow. Inspect the output of the final Merge node. You should see a list of 4 items. The two bug items will have triage_status: "Awaiting Fix", and the two feature items will have triage_status: "Backlog Review".


Conclusion

Congratulations, you have successfully built a workflow that demonstrates the complete "Filter, Branch, Process, Merge" pattern. This is a significant milestone. You've combined multiple control flow concepts into a single, logical process that transforms a dataset according to a set of rules.

Key Takeaways:

  • The "Filter, Branch, Process, Merge" pattern is a core architectural pattern for building complex and efficient workflows.
  • Filter data early using the Filter node to reduce unnecessary processing.
  • Branch your workflow using the Switch node for multi-path routing based on data values.
  • Process each branch independently to apply specific logic or transformations.
  • Merge the branches back together using the Merge node (usually in Append mode) to create a unified output.

You now have a solid command of n8n's control flow capabilities. You can direct, split, iterate, and combine data streams to create sophisticated logic.

In the next module, "HTTP Requests and Webhooks," we will move beyond using predefined, static data. You'll learn how to use the HTTP Request node to fetch data from any API on the web and the Webhook node to trigger your workflows from external systems. This will empower you to apply these powerful control flow patterns to dynamic, real-world data from your CI/CD tools and other services.