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:
- Filter out all
lowpriority issues. - Route
bugreports andfeaturerequests down separate paths. - Assign a
triage_statusto each type: "Awaiting Fix" for bugs and "Backlog Review" for features. - Merge the processed issues back into a single list for final review.
Step 1: Create the Mock Data
First, create a new, blank workflow.
- Your workflow starts with the default Manual trigger (the "Start" node).
- Add a Set node and name it
Create Mock Issues. - Ensure Mode is set to
Append. - Click Add Value and select Expression.
- In the Name field, type
issues. - 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.
- Add a Code node. It's the most straightforward way to do this.
- Change the Mode to
Run Once for All Items. - Make sure the language is Python.
- Paste the following code. This takes the
issuesarray 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.
- Add a Filter node after the Code node. Name it
Filter Low Priority. - Click Add Condition.
- In the first value box, use an expression to get the priority:
{{ $json.priority }}. - Set the operator to
Not Equal. - 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.
- Add a Switch node after the
Filternode. - For the Value to Switch On, use the expression
{{ $json.type }}. - Change the Data Type to
String. - Under Routing Rules, click Add Routing Rule.
- Set the first rule's Value to
bug. - Set the second rule's Value to
feature. - This will create three outputs on the node:
bug,feature, anddefault.
Step 5: Process Each Branch
Now we'll add a Set node to each branch to perform the path-specific processing.
- From the
bugoutput of theSwitchnode, add a Set node. Name itProcess Bugs. - Set Mode to
Append. - Add a field named
triage_statuswith the string valueAwaiting Fix. - From the
featureoutput of theSwitchnode, add another Set node. Name itProcess Features. - Set Mode to
Append. - Add a field named
triage_statuswith the string valueBacklog Review.
Step 6: Merge the Branches
Finally, let's bring our processed data streams back together.
- Add a Merge node to the canvas.
- Connect the output of the
Process Bugsnode to the Input 1 of theMergenode. - Connect the output of the
Process Featuresnode to the Input 2 of theMergenode. - Open the
Mergenode. The default Mode isAppend, 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.

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
Filternode to reduce unnecessary processing. - Branch your workflow using the
Switchnode 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
Mergenode (usually inAppendmode) 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.