CrystalFlow includes built-in nodes for common workflow patterns. These nodes are production-ready and fully tested.Documentation Index
Fetch the complete documentation index at: https://crystalflow.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
Flow Control Nodes
IfNode
Classic if/else conditional branching.'flow.if'Category:
'Flow Control'Implements:
IConditionalNode
Inputs
Boolean condition that determines which branch to execute.
true→ routes tothenOutputfalse→ routes toelseOutput
Optional data to pass through to the active branch. The value is set on either
thenOutput or elseOutput depending on the condition.Outputs
Output for the ‘then’ branch (when condition is true). Contains the passthrough
value if provided, otherwise undefined.
Output for the ‘else’ branch (when condition is false). Contains the passthrough
value if provided, otherwise undefined.
Methods
'thenOutput' if condition is true, 'elseOutput' if false.
Throws: Error if condition is not a boolean value.
Example
Usage in WorkflowBuilder
SwitchNode
Multi-way branching with case matching (switch/case pattern).'flow.switch'Category:
'Flow Control'Implements:
IConditionalNode
Inputs
Value to match against case values. Compared using strict equality (
===).Optional data to pass through to the matching branch. The data is set on the
matching case output or default output.
Properties
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 thecases property.
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’).
Default output used when no case matches. Always present regardless of the
number of cases.
Methods
'case_X' where X is the index of the matching case, or 'default'
if no case matches.
Example
Dynamic Outputs Example
Usage in WorkflowBuilder
cases property, allowing you to add/remove cases
interactively. Outputs update in real-time as cases change.
Comparison
| Feature | IfNode | SwitchNode |
|---|---|---|
| Branches | 2 (then/else) | N + 1 (cases + default) |
| Condition Type | Boolean | Any (strict equality) |
| Dynamic Outputs | No | Yes |
| Use Case | Simple binary decisions | Multi-way routing |
| Example | Valid/Invalid, Yes/No | Status routing, Type routing |
Best Practices
Use IfNode for Binary Decisions
Use IfNode for Binary Decisions
For simple true/false or valid/invalid scenarios, IfNode is clearer and
more efficient than SwitchNode with 2 cases.
Use SwitchNode for Multi-Way Routing
Use SwitchNode for Multi-Way Routing
When you have 3+ possible values to route on, SwitchNode is more maintainable
than nested IfNodes.
Always Handle Default Case
Always Handle Default Case
Connect a handler to the default output of SwitchNode to gracefully handle
unexpected values.
Type-Safe Matching
Type-Safe Matching
SwitchNode uses strict equality (===). Ensure your values and cases are the
same type (‘1’ !== 1).
Related
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