Branch
branch · Nodes · Control
Routes execution through named output branches.
Routes input data to exactly one output. Every other output ends its branch, so nothing downstream of it runs.
Existing workflows use index mode by default.
Inputs:
input- data to route
Outputs:
- One output per branch (see the modes below), then
default. default- always present. Receives the input when the expression selects no other output. When nothing is wired to it, the value is still emitted there and nothing downstream runs; the node does not fail. To fail on an unmatched value, wire a JavaScript node that throws todefault.
Configuration:
mode-indexorkeyexpression- JavaScript expression. Access input viainputs.input.num_branches- index mode: number ofoutput_0..output_nsockets (1-10). Key mode: derived, the number ofoutput_keys; a stored value is ignored.output_keys- key mode: required non-empty output socket names.defaultis reserved, and so iserrorwhen the failure mode is Route to error output.
Index mode:
- Outputs are
output_0…output_{num_branches-1}, thendefault. - A non-negative integer below
num_branchesgoes to that output. - Anything else goes to
default: a larger or negative number, a fraction, a boolean, a string,null, an object or array.
Key mode:
- Outputs are the
output_keysin order, thendefault. N keys give N+1 outputs. - A string equal to a key goes to that key.
- Anything else goes to
default: an unknown string, a number, a boolean,null, an object or array.
See Also:
if- routes based on truthinessselector- routes by input key without JavaScript
Inputs
inputRequired
Outputs
output_0output_1default
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
mode | enum(index, key) | No | How the expression selects an output |
expression | code(javascript) | No | JavaScript expression that returns an output index or key. Access input via inputs.input. A result that selects no output goes to default. |
num_branches | number | No | Number of output branches in index mode (1-10), plus the default output. In key mode it is the number of output_keys. |
output_keys | array<string> | No | Output socket keys for key routing mode. A value matching no key goes to the default output. default is reserved, and so is error when the failure mode is Route to error output. |
base_config | record | No | Shared node configuration. failure_mode decides what a failure of this node does to the workflow; leave it at the default stop unless the workflow handles the failure itself on the node's error output (route_to_error) or the node is a rare emergency kill switch (stop_workflow). |