节点与集成
Execute Sub-workflow
Use the Execute Sub-workflow node to run a different workflow on the host machine that runs n8n.
Node parameters
Source
Select where the node should get the sub-workflow's information from:
- Database: Select this option to load the workflow from the database by ID. You must also enter either:
- From list: Select the workflow from a list of workflows available to your account.
- Workflow ID: Enter the ID for the workflow. The URL of the workflow contains the ID after
/workflow/. For example, if the URL of a workflow ishttps://my-n8n-acct.app.n8n.cloud/workflow/abCDE1f6gHiJKL7, the Workflow ID isabCDE1f6gHiJKL7. - Local File: Select this option to load the workflow from a locally saved JSON file. You must also enter:
- Workflow Path: Enter the path to the local JSON workflow file you want the node to execute.
- Parameter: Select this option to load the workflow from a parameter. You must also enter:
- Workflow JSON: Enter the JSON code you want the node to execute.
- URL: Select this option to load the workflow from a URL. You must also enter:
- Workflow URL: Enter the URL you want to load the workflow from.
Workflow Inputs
If you select a sub-workflow using the database and From list options, the sub-workflow's input items will automatically display, ready for you to fill in or map values.
You can optionally remove requested input items, in which case the sub-workflow receives null as the item's value. You can also enable Attempt to convert types to try to automatically convert data to the sub-workflow item's requested type.
Input items won't appear if the sub-workflow's Workflow Input Trigger node uses the "Accept all data" input data mode.
Mode
Use this parameter to control the execution mode for the node. Choose from these options:
- Run once with all items: Pass all input items into a single execution of the node.
- Run once for each item: Execute the node once for each input item in turn.
Node options
This node includes one option: Wait for Sub-Workflow Completion. This lets you control whether the main workflow should wait for the sub-workflow's completion before moving on to the next step (turned on) or whether the main workflow should continue without waiting (turned off).
Templates and examples
Browse Execute Sub-workflow integration templates or search all templates
Set up and use a sub-workflow
This section walks through setting up both the parent workflow and sub-workflow.
Create the sub-workflow
- Create a new workflow.
Create sub-workflows from existing workflowsYou can optionally create a sub-workflow directly from an existing parent workflow using the Execute Sub-workflow node. In the node, select the Database and From list options and select Create a sub-workflow in the list.You can also extract selected nodes directly using Sub-workflow conversion in the context menu.
- Optional: configure which workflows can call the sub-workflow:
- Select the Options
menu > Settings. n8n opens the Workflow settings modal.
- Change the This workflow can be called by setting. Refer to Workflow settings for more information on configuring your workflows.
- Add the Execute Sub-workflow trigger node (if you are searching under trigger nodes, this is also titled When Executed by Another Workflow).
- Set the Input data mode to choose how you will define the sub-workflow's input data:
- Define using fields below: Choose this mode to define individual input names and data types that the calling workflow needs to provide. The Execute Sub-workflow node or Call n8n Workflow Tool node in the calling workflow will automatically pull in the fields defined here.
- Define using JSON example: Choose this mode to provide an example JSON object that demonstrates the expected input items and their types.
- Accept all data: Choose this mode to accept all data unconditionally. The sub-workflow won't define any required input items. This sub-workflow must handle any input inconsistencies or missing values.
- Add other nodes as needed to build your sub-workflow functionality.
- Save the sub-workflow.
Call the sub-workflow
- Open the workflow where you want to call the sub-workflow.
- Add the Execute Sub-workflow node.
- In the Execute Sub-workflow node, set the sub-workflow you want to call. You can choose to call the workflow by ID, load a workflow from a local file, add workflow JSON as a parameter in the node, or target a workflow by URL.
Find your workflow IDYour sub-workflow's ID is the alphanumeric string at the end of its URL.
- Fill in the required input items defined by the sub-workflow.
- Save your workflow.
When your workflow executes, it will send data to the sub-workflow, and run it.
You can follow the execution flow from the parent workflow to the sub-workflow by opening the Execute Sub-workflow node and selecting the View sub-execution link. Likewise, the sub-workflow's execution contains a link back to the parent workflow's execution to navigate in the other direction.
How data passes between workflows
As an example, imagine you have an Execute Sub-workflow node in Workflow A. The Execute Sub-workflow node calls another workflow called Workflow B:
- The Execute Sub-workflow node passes the data to the Execute Sub-workflow Trigger node (titled "When executed by another node" in the canvas) of Workflow B.
- The last node of Workflow B sends the data back to the Execute Sub-workflow node in Workflow A.
官方原文和授权
本页来自 N8N 英文官方网站固定快照,并转换成 xueai 静态页面。内容以 N8N 持续更新的官方页面为准。