Ep 27: Modular Construction — Sub-Workflows & Workflow Tool

⏱ Est. reading time: 6 min Updated on 4/9/2026

Why Sub-Workflows?

When a workflow exceeds 20 nodes, maintainability drops fast. Sub-workflows are n8n's modularization mechanism.

1. Execute Workflow Node

sequenceDiagram
    participant Main as 📋 Main Workflow
    participant Sub as 📦 Sub-Workflow
    Main->>Sub: Pass input Items
    Sub->>Sub: Execute logic
    Sub-->>Main: Return output Items
// Mode:
// "Wait" (sync): wait for completion — when you need the return value
// "Don't Wait" (async): fire and forget — for notifications

2. Workflow Tool (Agent Calls Sub-workflows)

graph TB
    Agent[🤖 AI Agent] --> WT1["🔗 'Query Orders' (sub-workflow)"]
    Agent --> WT2["🔗 'Generate Report' (sub-workflow)"]
    Agent --> WT3["🔗 'Send Email' (sub-workflow)"]
    style Agent fill:#ff6d5b,stroke:#e55a4e,color:#fff

3. Design Patterns

Pattern Use Case Flow
Pipeline Sequential processing A → B → C
Fan-out Parallel notifications Main → Slack + Email + DB
Router Type-based dispatch Switch → Handler A / B

Next Episode

Ep 28: Version control & team collaboration — Git integration, environment management, multi-env deployment.