Skip to content

SubWorkflow

The SubWorkflow module allows executing another workflow as a sub-process within the current flow. It supports three execution modes: synchronous (waits for the result before continuing), asynchronous (launches and continues without waiting), and parallel (executes multiple instances if the input is an array). It can inherit the parent workflow state (workflowState) to share context between flows. Each execution generates a child instance with complete traceability, recording the parent-child relationship in the database. It is ideal for reusing workflow logic, splitting complex flows into manageable sub-processes, or executing batch operations.

The Sub Workflow node is designed to be understood at a glance, without opening the child flow to see what it points to.

On the canvas the node is rectangular: the icon on the left and, on the right, a band with the type, the execution mode (sync / async / parallel), the child workflow name and an ↗ link to open it in a new tab. The validation alert stays on the left, out of the way.

Rectangular Sub Workflow node: icon on the left and a band with type, mode, child workflow and open link

In the workflow list, every workflow that invokes sub-workflows shows a chevron that expands, nested underneath, the sub-workflows it calls. This lets you see the dependency tree without opening the editor. Workflows that call none show no chevron.

Workflow list with the sub-workflows nested under each parent

Recursion detection: when you pick the child workflow, the panel warns you if it creates a cycle —direct or indirect, of the form A → B → A— showing the full path. When there is no cycle, it shows the downstream call chain.

Node panel with the red recursion warning and the cycle path

ParameterTypeRequiredDescription
workflow_idworkflow_selectorYesSelects the workflow to be executed as a sub-process.
execution_modeselectYesExecution mode: sync (wait for result), async (fire & forget), parallel (multiple instances). Default: sync.
pass_statebooleanNoPasses the current workflowState to the sub-workflow. Default: true.
input_datacode_editorNoJSON data or variables to send as input to the sub-workflow. Supports dynamic variables.
timeout_msnumberNoMaximum wait time in synchronous mode (0 = no limit). Default: 30000.
{
"nextModule": "siguiente_modulo",
"data": {
"resultado_del_subworkflow": "valor"
}
}
{
"nextModule": "siguiente_modulo",
"data": {
"child_instance_id": "sub_workflow123_abc123",
"workflow_id": 456,
"workflow_name": "Proceso de envio",
"status": "launched",
"message": "Sub-workflow lanzado en modo asincronico"
}
}
{
"nextModule": "siguiente_modulo",
"data": {
"mode": "parallel",
"total": 3,
"success_count": 2,
"error_count": 1,
"results": [
{ "index": 0, "success": true, "instance_id": "sub_wf_abc_0", "data": {} },
{ "index": 1, "success": true, "instance_id": "sub_wf_abc_1", "data": {} }
],
"errors": [
{ "index": 2, "success": false, "instance_id": "sub_wf_abc_2", "error": "mensaje" }
]
}
}
{
"label": "Sub Workflow",
"workflow_id": "123",
"execution_mode": "sync",
"pass_state": true,
"input_data": "",
"timeout_ms": 30000
}
  • In sync mode, the parent flow waits for the sub-workflow to finish before continuing.
  • In async mode, the parent flow continues immediately. The sub-workflow runs in the background with setImmediate.
  • In parallel mode, if the input is an array, one sub-workflow instance is launched per element. Concurrency is limited to 5 simultaneous instances by default.
  • If pass_state is true, the parent’s workflowState is inherited by the sub-workflow.
  • If input_data is empty, the current node’s input data is used.
  • Each child instance is registered in the workflowinstances table with a reference to the parent.
  • The state of each child instance is automatically updated (completed/failed).
  • If the specified workflow does not exist or does not belong to the same client, an error is returned.
  • Supports dynamic variables in input_data.