If-Else
Conditionally route workflow execution based on typed comparison
Node Type
Conditional
Category
Control Flow
Icon
GitBranch
Overview
The If-Else node is a conditional node that compares two inputs after casting them to specified types and routes workflow execution to one of two paths based on the result. This powerful branching logic enables complex decision-making in your workflows, allowing you to create dynamic paths based on data comparisons and conditions.
Key Features
- • Type Casting: Automatically casts inputs to specified types before comparison
- • Flexible Operations: Supports equals, does not equal, contains, and does not contain
- • Dual Branching: Routes to true path (0) or false path (1) based on condition result
- • Type Safety: Handles string, boolean, and number types with proper casting
- • Condition Tracking: Returns the evaluated boolean result for downstream use
- • Dynamic Routing: Enables complex workflow logic and decision trees
Prerequisites
Workflow Structure
Must have downstream nodes for branching paths
Data Requirements
Understanding of data types and comparisons
Technical Requirements
System capabilities needed
Node Configuration
Required Fields
inputType
The type to cast both inputs to before comparison. All comparisons happen after casting to this type. Choose the type that best matches your data.
operation
The comparison operation to perform. Equals checks for exact match, does not equal checks for difference, contains checks if first value includes second (string/array), does not contain checks if first value excludes second.
input1
The first value to compare. Will be cast to the specified inputType before comparison.
input2
The second value to compare. Will be cast to the specified inputType before comparison.
Examples & Use Cases
String Comparison
Check if email domain matches company domain
{
"inputType": "string",
"operation": "contains",
"input1": "{{userEmail}}",
"input2": "@company.com"
}Routes to true path if the email contains "@company.com", false path otherwise. Useful for filtering internal vs external users.
Number Threshold
Route based on numeric value comparison
{
"inputType": "number",
"operation": "equals",
"input1": "{{orderTotal}}",
"input2": "0"
}Checks if order total equals zero. Can be used to skip payment processing for free orders.
Boolean Status Check
Route based on boolean flag
{
"inputType": "boolean",
"operation": "equals",
"input1": "{{user.isVerified}}",
"input2": "true"
}Routes verified users to one path and unverified users to another path for different handling.
Exclusion Check
Check if value does NOT contain unwanted content
{
"inputType": "string",
"operation": "does not contain",
"input1": "{{emailSubject}}",
"input2": "spam"
}Filters out emails that contain "spam" in the subject line.
Best Practices
Do's
- • Choose the correct input type for your data
- • Use clear, meaningful comparison values
- • Connect different nodes to each branch for proper routing
- • Test both true and false paths in your workflow
- • Use the condition output for debugging and logging
- • Consider type casting behavior when designing conditions
Don'ts
- • Don't forget that types are cast before comparison
- • Avoid using contains operation with number types
- • Don't create conditions that always evaluate to the same result
- • Avoid deeply nested if-else chains (consider AI Router instead)
- • Don't ignore the condition output for audit trails
- • Avoid comparing incompatible data types without proper casting
Troubleshooting
Common Issues
Unexpected Routing
Symptoms: Workflow routes to wrong branch
Solution: Check the inputType and ensure both values are being cast correctly. Remember that casting happens before comparison. Test with explicit values first before using template variables.
Contains Not Working
Symptoms: Contains operation doesn't find substring
Solution: Ensure inputType is set to 'string'. The contains operation works on strings and arrays. Check for case sensitivity and whitespace issues.
Boolean Comparison Issues
Symptoms: Boolean comparisons give unexpected results
Solution: When using boolean type, ensure values are exactly 'true' or 'false'. Truthy values (like '1', 'yes') may not cast as expected. Use explicit boolean values.