Contents

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 to default.

Configuration:

  • mode - index or key
  • expression - JavaScript expression. Access input via inputs.input.
  • num_branches - index mode: number of output_0..output_n sockets (1-10). Key mode: derived, the number of output_keys; a stored value is ignored.
  • output_keys - key mode: required non-empty output socket names. default is reserved, and so is error when the failure mode is Route to error output.

Index mode:

  • Outputs are output_0 … output_{num_branches-1}, then default.
  • A non-negative integer below num_branches goes 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_keys in order, then default. 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 truthiness
  • selector - routes by input key without JavaScript

Inputs

  • inputRequired

Outputs

  • output_0
  • output_1
  • default

Configuration

FieldTypeRequiredDescription
modeenum(index, key)NoHow the expression selects an output
expressioncode(javascript)NoJavaScript expression that returns an output index or key. Access input via inputs.input. A result that selects no output goes to default.
num_branchesnumberNoNumber of output branches in index mode (1-10), plus the default output. In key mode it is the number of output_keys.
output_keysarray<string>NoOutput 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_configrecordNoShared 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).