Skip to main content
CrystalFlow includes built-in nodes for common workflow patterns. These nodes are production-ready and fully tested.

Flow Control Nodes

IfNode

Classic if/else conditional branching.
Type: 'flow.if'
Category: 'Flow Control'
Implements: IConditionalNode

Inputs

boolean
required
Boolean condition that determines which branch to execute.
  • true → routes to thenOutput
  • false → routes to elseOutput
any
Optional data to pass through to the active branch. The value is set on either thenOutput or elseOutput depending on the condition.

Outputs

any
Output for the ‘then’ branch (when condition is true). Contains the passthrough value if provided, otherwise undefined.
any
Output for the ‘else’ branch (when condition is false). Contains the passthrough value if provided, otherwise undefined.

Methods

Sets the active output (thenOutput or elseOutput) based on the condition value. The inactive output is set to undefined.
Returns 'thenOutput' if condition is true, 'elseOutput' if false. Throws: Error if condition is not a boolean value.

Example

Usage in WorkflowBuilder

The IfNode appears in the “Flow Control” category of the node palette.

SwitchNode

Multi-way branching with case matching (switch/case pattern).
Type: 'flow.switch'
Category: 'Flow Control'
Implements: IConditionalNode

Inputs

any
required
Value to match against case values. Compared using strict equality (===).
any
Optional data to pass through to the matching branch. The data is set on the matching case output or default output.

Properties

any[]
default:"[]"
Array of case values to match against. The number of cases determines how many output ports are created (case_0, case_1, …, case_N, default).Dynamic Outputs: When cases are added or removed, the node automatically updates its output ports.

Outputs

Dynamic: Outputs are generated based on the cases property.
any
One output for each case in the cases array. The label shows the actual case value (e.g., if cases[0] is ‘apple’, the label is ‘apple’).
any
Default output used when no case matches. Always present regardless of the number of cases.

Methods

Dynamically generates output port definitions based on the cases array.
Clears all outputs, then finds the matching case and sets only that output (or the default output if no match).
Returns 'case_X' where X is the index of the matching case, or 'default' if no case matches.

Example

Dynamic Outputs Example

Usage in WorkflowBuilder

The SwitchNode appears in the “Flow Control” category. The property panel shows an array editor for the cases property, allowing you to add/remove cases interactively. Outputs update in real-time as cases change.

Comparison

Best Practices

For simple true/false or valid/invalid scenarios, IfNode is clearer and more efficient than SwitchNode with 2 cases.
When you have 3+ possible values to route on, SwitchNode is more maintainable than nested IfNodes.
Connect a handler to the default output of SwitchNode to gracefully handle unexpected values.
SwitchNode uses strict equality (===). Ensure your values and cases are the same type (‘1’ !== 1).

Conditional Flow Guide

Complete guide to conditional workflows

IConditionalNode

Interface for creating custom conditional nodes

Conditional Logic Examples

Working examples with If and Switch nodes

Creating Custom Nodes

Build your own conditional nodes