Get startedGet started for free

Sub-Workflows and Modular Design

1. Sub-Workflows and Modular Design

As workflows grow, you'll often find yourself copying the same logic into multiple places — a transformation here, a duplicate there. It works at first, but it quickly becomes a maintenance headache. Let's look at a common example.

2. One Workflow to Rule Them All!

Here's a workflow that processes incoming orders. A Manual Trigger feeds into an If node that checks the priority field — high-priority orders go one way, low-priority go the other. Both branches need the same transformation: an Edit Fields node that adds a processed flag set to true and a processed_at timestamp. Notice the True branch has it configured, and the False branch has an identical copy. It works — but here's where it gets painful. Say we get a request to add a processed_by field to track which system handled it. We update the Edit Fields on the True branch, but forget about the False branch — or it gets updated slightly differently. Now high-priority and low-priority orders are being processed inconsistently, and we might not notice until something breaks downstream. And this is just two branches in one workflow. Imagine five different workflows all needing that same transformation — now we're hunting across our entire n8n instance to keep them in sync.

3. Modular Workflows

Sub-workflows fix this. They let you extract that shared logic into its own separate workflow — define it once, and any workflow can call it. Change it in one place, every caller gets the update.

4. Modular Workflows

Previously, we used the HTTP Request and Webhook Trigger nodes to trigger a sub-workflow in a producer-consumer pattern. This worked great, and what's nice about this pattern is that the producer doesn't have to be an n8n workflow, it can be any system able to send API requests. However, when we are dealing with multiple sub-workflows in a modular design, there's an even sleeker node pattern we can use!

5. Executing Sub-Workflows

There's actually a dedicated node for executing sub-workflows — the Execute Sub-workflow node. No HTTP requests, no production URLs — just select the workflow you want to call, and n8n handles the rest. On the sub-workflow side, it starts with an Execute Sub-workflow Trigger instead of a Webhook Trigger. Data flows in the same way — the parent passes items to the child, and the child can return results. Let's see this in action!

6. Example: Conditional Processing

Let's build a ticket routing system. We've got a Manual Trigger with a test ticket pinned — it has a subject, a severity set to "critical," and a description. The goal is to route critical tickets to an escalation sub-workflow and standard tickets to a simpler acknowledgement workflow Start by adding an If node after the trigger. Set the condition to check whether the severity field equals "critical." Now add two Execute Sub-workflow nodes — one on each branch. On the True branch, select the escalation sub-workflow. On the False branch, select the acknowledgment sub-workflow. Each one is chosen by name from the workflow picker. Let's peek at the escalation sub-workflow. It starts with an Execute Sub-workflow Trigger — that's what receives the data from the parent. After the trigger, an Edit Fields node stamps three fields onto the ticket: escalated set to true, an escalated_at timestamp, and an assigned_to field set to "senior-engineering." Back in the parent workflow, we execute it. The test ticket has severity "critical," so it takes the True branch and calls the escalation sub-workflow. Open the escalation sub-workflow's executions — the ticket arrived with all its original fields, plus the three new ones stamped-on by the sub-workflow. Each sub-workflow is focused, testable, and reusable — and the parent stays clean.

7. Let's practice!

Time to try this out for yourself!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.