Intermediate
How to create sub-workflow modules on n8n
Quick Answer
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
1
Create the Sub-workflow
Navigate to your n8n dashboard and click + New Workflow. Build your sub-workflow with the necessary nodes and logic. Ensure the workflow has a clear Webhook or Manual Trigger node as the starting point. Add a Respond to Webhook node at the end to return data to the parent workflow. Save the workflow with a descriptive name like
Sub-Process-UserValidation.Tip
Keep sub-workflows focused on a single responsibility for better maintainability
2
Configure the Webhook Trigger
In your sub-workflow, click on the Webhook node and set the HTTP Method to
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.Tip
Use authentication on webhook triggers to prevent unauthorized access
3
Activate the Sub-workflow
Click the Active toggle switch in the top-right corner of the sub-workflow editor. Ensure the status shows Active with a green indicator. Test the sub-workflow by clicking Test workflow and sending sample data to verify it processes correctly and returns the expected output.
4
Add Execute Workflow Node to Parent
In your main workflow, click the + button to add a new node. Search for and select Execute Workflow from the node list. In the node settings, set Source to
Database and select your sub-workflow from the Workflow dropdown menu.Tip
You can also use the webhook URL method by setting Source to 'URL' instead
5
Configure Data Passing
In the Execute Workflow node, configure the Fields to Send section. Add the data fields you want to pass to the sub-workflow using expressions like
{{ $json.fieldName }}. Set the Wait for Sub-Workflow option to true if you need to receive data back from the sub-workflow.Tip
Use the expression editor to dynamically pass data from previous nodes
6
Handle Return Data
Add nodes after the Execute Workflow node to process the returned data. The sub-workflow's output will be available in
{{ $json }} format. Use Set nodes or Code nodes to transform or extract specific values from the returned data structure.Tip
Always validate the structure of returned data to prevent workflow errors
7
Test the Integration
Click Execute Workflow on your main workflow to test the sub-workflow integration. Check the Executions tab to monitor both the parent and sub-workflow executions. Verify that data flows correctly between workflows and that error handling works as expected.
Tip
Use the workflow execution history to debug any data passing 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.
Ready to get started with n8n?
Put this tutorial into practice. Visit n8n and follow the steps above.
Visit n8n →