Guide: Chain Workflows with Subworkflow
Build a parent workflow that calls two separate subworkflows in sequence, passing data between them. This pattern is useful for keeping complex workflows modular and reusable.
What you will build:
Parent: Webhook → Subworkflow A (validate) → Subworkflow B (notify) → Return
Child A: Manual Trigger → HTTP Request (validate) → Return
Child B: Manual Trigger → Send Email → Return
Time: ~20 minutes
Prerequisites:
- Tensorify account with a workspace
- Resend account with a verified domain
- CLI installed:
npm install -g @tensorify.io/cli
This workflow takes a user ID and returns the user's data.
- Dashboard → New Workflow → name it
validate-user - Add a Manual trigger with
allowWorkflowInvocationenabled - Set mock payload:
{ "userId": "usr_123" }
-
Add an HTTP Request node connected to Manual's payload:
- Method: GET
- URL:
https://jsonplaceholder.typicode.com/users/{{ manual.body.userId }}
-
Add an If node connected to HTTP Request's response:
- Condition:
{{ http_request.status }} == 200
- Condition:
-
On the true branch: add a Return node connected to HTTP Request's response
-
On the false branch: add a Return node connected to a Transform node that produces:
{ "error": "User not found", "userId": "{{ manual.body.userId }}" }
Copy the Workflow ID from the URL — you will need it in the parent workflow.
This workflow sends an email notification with the user data.
- Dashboard → New Workflow → name it
send-user-notification - Add a Manual trigger with
allowWorkflowInvocationenabled - Set mock payload:
{
"name": "Test User",
"email": "[email protected]"
}
- Add a Code node connected to Manual's payload:
name = input.get("body", {}).get("data", {}).get("name", "User")
return f"New user validated: {name}"
-
Add a Send Email node connected to Code's result:
- From:
[email protected] - To:
[email protected] - Subject:
User validated: {{ manual.body.data.name }}
- From:
-
Add a Return node connected to a Transform that produces:
{ "notified": true, "userId": "{{ manual.body.data.id }}" }
Copy this workflow's Workflow ID too.
- Dashboard → New Workflow → name it
user-onboarding-pipeline - Add a Webhook node (or API Endpoint if you want a synchronous response)
- Add a Subworkflow node connected to Webhook's payload:
- Workflow ID: paste the ID of
validate-user
- Workflow ID: paste the ID of
- Add another Subworkflow node connected to the first Subworkflow's result:
- Workflow ID: paste the ID of
send-user-notification
- Workflow ID: paste the ID of
- Connect the second Subworkflow's result to a Return node (if using API Endpoint)
export TENSORIFY_API_KEY="your_key_here"
tensorify watch user-onboarding-pipeline-workflow-id
Set a mock payload on the Webhook node:
{ "userId": "3" }
Click Test → select the Return node → click Run to Selected.
In the terminal, you will see execution logs from all three workflows in sequence. The canvas shows the parent and each subworkflow's outputs at each step.
All three workflows need to be running for CLI execution mode to work. Either:
- Run each in a separate terminal:
tensorify run <workflowId>for each - Or set execution mode to Managed for the subworkflows
In practice, subworkflows inherit the execution context. You only need tensorify run for the parent workflow if all workflows share the same runner configuration.
- How to compose multiple workflows using the Subworkflow node
- How to pass data between parent and child workflows via the
inputhandle andReturnnode - How to use If branching inside a subworkflow to handle error states
- The module composition pattern for keeping complex automations maintainable
- Subworkflow reference — full configuration options
- Return reference — returning values from subworkflows
- Manual Trigger reference — configuring invokable workflows
