Run another workflow
Call one workflow from another as a step, and use what it returns.
Build a job once, such as “look up the customer”, and call it from every workflow that needs it.
Look up the customer runs another workflow, waits for it, and passes its result to step 02.
Set up the workflow you call
- In the workflow to call, press Add a trigger and choose When Called by Another Workflow.
- In Expected Input, write a sample of what it receives, such as
{"email": "ada@acme.example"}. - In its steps, use the input as
{{trigger.email}}. - Press Publish.
The sample is the agreement between the two workflows: the calling step fills its Input from it, and a test of this workflow uses it.
Call it
- In the other workflow, add a step: type
sub-flowand choose Sub-flow. - Under Workflow, choose the one to call.
- In Input, put in your values, such as
{"email": "{{trigger.body.email}}"}.
Later steps read what it returned: {{steps.step_1.output}} is its last step’s output, and {{steps.step_1.steps}} holds every step’s.
What to know
- It waits
- The step waits until the other workflow ends. There is no option to carry on without waiting.
- Its version
- It runs the published version of the workflow you call, or its draft if it was never published.
- If it fails
- The step fails too, with the reason, and the step’s On error decides what happens next.
- Its own run
- On a run’s page, the step’s Output names the workflow it ran and shows what came back. Open that run shows every step inside it.
- Time
- It must finish within both workflows’ time limits.
- Depth
- Workflows can call each other 5 levels deep. A workflow that calls itself stops there.
Note In a workflow you call, an approval fails, and a Delay longer than 5 minutes fails. Put waits in the calling workflow.
Check it worked
Press Test in the calling workflow. The Sub-flow card shows Worked, and its Result shows what came back.
For developers
The step is pieceId: "subflow", actionId: "execute", with config.workflow_id and config.input. The trigger is callable (called_by_flow). Its output also has subRunId, the id of the other workflow’s run. See Workflow definition.
Related
- Sub-flowEvery field and output
- Handle errorsWhat happens when the called workflow fails · 4 min
- Use data from earlier stepsExpressions and the Data pane · 5 min
Checked against 12d85b3b