Overview

The Switch Block is a control flow block that routes the input value to different outputs based on a boolean condition. It evaluates the condition and directs the value to either the True or False output port accordingly.

Key Features

  • Routes values based on a condition
  • Control flow excluded values for unmatched paths

Inputs

Condition
any

If this is truthy, the value will be passed through the True port. Otherwise, it will be passed through the False port. An unconnected port is considered false.

Value
any

The value to pass through the True or False port. If unconnected, it will be undefined.

Outputs

True
any

The value passed through if the condition is truthy. Control-flow-excluded if condition is falsy.

False
any

The value passed through if the condition is falsy. Control-flow-excluded if condition is truthy.

Editor Settings

Don't run unconnected value
boolean
default:true

If enabled, unconnected value input is control-flow-excluded. If disabled (legacy behavior), unconnected value will pass through undefined.

Width
number
default:150

The width of the block in pixels.

Example: Route a message based on a condition

  1. Create a Bool Block and set its value to true.
  2. Create a Text Block with the value “Hello, World!”.
  3. Create a Switch Block. Connect the Bool Block to Condition and the Text Block to Value.
  4. Add two Text Blocks to display the output, one connected to True and one to False.
  5. Run the flow. The “Hello, World!” message should appear in the Text Block connected to True.
  6. Change the Bool Block to false and run again. The message should now appear in the Text Block connected to False.

Error Handling

The Switch block will not throw an error under normal circumstances. The following values are considered falsy:

  • Boolean false
  • Empty string
  • Empty array
  • Control-flow-excluded values
  • Undefined/unconnected inputs
  • Empty chat messages

FAQ

See Also