How to create sub-workflow modules on n8n
Sub-workflow modules in n8n are created using the Execute Workflow node to call other workflows as reusable components. This allows you to build modular, maintainable automation by breaking complex processes into smaller, focused workflows.
Prerequisites
- Basic n8n workflow creation experience
- Understanding of JSON data structure
- Active n8n instance or cloud account
Step-by-Step Instructions
Create the Sub-workflow
Sub-Process-UserValidation.Configure the Webhook Trigger
POST. Set the Path to something descriptive like /validate-user. Under Authentication, choose your preferred security method. Copy the generated webhook URL as you'll need it for the parent workflow.Activate the Sub-workflow
Add Execute Workflow Node to Parent
Database and select your sub-workflow from the Workflow dropdown menu.Configure Data Passing
{{ $json.fieldName }}. Set the Wait for Sub-Workflow option to true if you need to receive data back from the sub-workflow.Handle Return Data
{{ $json }} format. Use Set nodes or Code nodes to transform or extract specific values from the returned data structure.Test the Integration
Common Issues & Troubleshooting
Sub-workflow not executing when called
Ensure the sub-workflow is activated and the Execute Workflow node has the correct workflow selected. Check that webhook authentication settings match between parent and sub-workflows.
Data not passing correctly between workflows
Verify the Fields to Send configuration in the Execute Workflow node. Check that field names match exactly and use the expression editor to validate data mapping with {{ $json.fieldName }} syntax.
Timeout errors when calling sub-workflows
Increase the Timeout value in the Execute Workflow node settings. Optimize the sub-workflow by reducing unnecessary nodes or processing time, and ensure external API calls have appropriate timeout settings.
Sub-workflow executions not visible in history
Check that Save Execution Progress is enabled in workflow settings. Ensure the sub-workflow has proper error handling nodes and that the Respond to Webhook node is correctly configured to send data back.