
Module 5 Lesson 5: Global Workflows
Libraries of logic. Learn how to create 'Sub-Workflows' that can be called by multiple other workflows, making your automation standard and easy to maintain.
Module 5 Lesson 5: Global Workflows
Just like "Templates" in GitLab (Course 9), n8n has Sub-Workflows. If you use the same "Calculate Insurance Tax" logic in 5 different workflows, don't build it 5 times. Build it ONCE and use the Execute Workflow node.
1. The "Parent" and "Child" Model
- The Child: A workflow that starts with an "Execute Workflow Trigger". It does the hard work and returns data.
- The Parent: Your main workflow. It uses the "Execute Workflow" node to "Call" the child.
2. Passing Data
When you call a child workflow:
- You "Pass" items from the parent.
- The child sees these items as if they came from its first node.
- The child finishes and "Hands back" the result to the parent.
Visualizing the Process
graph TD
Start[Input] --> Process[Processing]
Process --> Decision{Check}
Decision -->|Success| End[Complete]
Decision -->|Retry| Process
3. Why Use Modular Workflows?
- Maintenance: Need to change the tax rate? Update 1 child workflow, and all 5 parents are fixed.
- Speed: You can build a huge, complex system by just "Wiring together" small, tested components.
- Organization: Your canvas stays "Clean." You don't have 100 nodes in one view.
4. Error Handling at Scale
You can wrap an Execute Workflow node in its own "Try/Catch" logic.
- "Call the 'Charge Credit Card' sub-workflow."
- "If it fails, call the 'Notify Customer' sub-workflow."
Exercise: The Architect's Design
- Create a "Calculator" child workflow. It should take a number and multiply it by 10. (Use an Execute Workflow Trigger).
- Create a "Main" workflow. Add an Execute Workflow node that calls your Calculator.
- Pass the number
5to it. Run the Main workflow. Did you get50back? - Research: Can you call a workflow that lives on a DIFFERENT n8n server? (Hint: Use the HTTP Request node and the n8n API).
- Why is this better for a team of 5 people than everyone building their own "Slack notification" logic?
Summary
You have completed Module 5: Advanced Logical Flow. You now know how to handle complex decisions, batch heavy loads, catch errors, loop through items, and build modular, reusable architectures. You are officially an n8n Power User.
Next Module: Talking to the world: Module 6: Connecting to APIs and Webhooks.