Condition Step
The Condition step adds branching logic to your flows by evaluating conditions using the rules engine. Based on the conditions you define, the flow routes to different next steps—or terminates with success or error.How Conditions Work: The Condition step uses the same rules engine as the Rules step, but instead of calculating values, it routes the flow based on which condition matches first. Conditions are checked top-to-bottom until one matches.
How It Works
The Condition step evaluates conditions in sequence and routes to the outcome of the first matching condition:Configuration
Facts
Just like the Rules step, you define facts that will be evaluated by the conditions. Facts are populated using variable mapping from previous steps:Fact keys don’t need the
.value suffix in the Condition step—the system handles this automatically.Conditions Array
Conditions are evaluated top-to-bottom. The first matching condition’s outcome is used:Special Outcomes
Instead of routing to another step, you can terminate the flow:"RESOLVE_SUCCESS"- End the flow successfully"RESOLVE_ERROR"- End the flow with an error
Condition Syntax
Conditions use the same operator-based syntax as the Rules step. See the Rules Operations Reference for all available operators.Basic Comparisons
Logical Operators
Null Checks
String Operations
Array Operations
Common Patterns
Agent Decision Routing
Agent Decision Routing
Route based on agent’s structured output decisionFacts:Conditions:
Threshold-Based Routing
Threshold-Based Routing
Route based on numeric thresholdsFacts:Conditions:
Multi-Factor Validation
Multi-Factor Validation
Check multiple criteria before proceedingFacts:Conditions:
Status-Based Routing
Status-Based Routing
Route based on status or categoryFacts:Conditions:
Confidence-Based Routing
Confidence-Based Routing
Route based on AI confidence scoresFacts:Conditions:
Error Handling & Validation
Error Handling & Validation
Validate data and route errors appropriatelyFacts:Conditions:
Data Completeness Check
Data Completeness Check
Verify required fields exist before processingFacts:Conditions:
Best Practices
Always Have Default
Always include a final condition with no condition expression (just
{"outcome": "..."}) to handle unexpected values.Order Matters
Conditions are evaluated top-to-bottom. Put most specific conditions first, most general last.
Use Agent Output Schemas
When routing based on agent decisions, use output schemas for clean, predictable conditions.
Test All Branches
Test each condition path with appropriate test data to ensure all outcomes work correctly.
Keep It Simple
For very complex logic, consider using a Rules step to calculate intermediate values, then use a Condition step for routing.
Document Branches
Use clear, descriptive names for outcome steps so the flow is easy to understand.
When to Use Conditions vs. Rules
| Use Condition When | Use Rules When |
|---|---|
| Need to route flow to different steps | Need to calculate values |
| Binary or multi-way branching | Complex calculations or transformations |
| Flow termination needed | Data reshaping needed |
| Decision → Action mapping | Multiple derived values needed |
- Rules step calculates complex values
- Condition step routes based on those calculated values
Complete Example
Here’s a complete example showing Facts, Conditions, and routing: Scenario: Route customer support requests based on agent analysis Step Configuration:- If agent says human required → Human review
- If refund with high confidence → Auto-process refund
- If technical with high confidence → Technical support flow
- If marked urgent → Urgent escalation
- If low confidence → Manual review
- Default → Standard support queue
Troubleshooting
Flow fails at condition step
Flow fails at condition step
Possible causes:
- No conditions matched and no default outcome
- Fact reference is incorrect
- Data type mismatch
- Variable mapping failed
- Always add a default condition with no condition expression
- Verify fact keys match your facts object
- Check data types (comparing string to number won’t match)
- Verify previous step output contains expected data
- Add logging steps before condition to inspect values
Wrong branch taken
Wrong branch taken
Possible causes:
- Condition order wrong (earlier condition matched first)
- Logical operator error (AND vs. OR)
- Data type mismatch
- Operator precedence unexpected
- Reorder conditions (most specific first)
- Verify logical operators are correct
- Check data types match (use type conversion if needed)
- Test each condition individually
- Add logging to see which condition matched
Condition always false
Condition always false
Possible causes:
- Fact doesn’t exist or is null
- Variable mapping returned unexpected format
- Case sensitivity issue
- Whitespace in data
- Check previous step output structure
- Add null checks using
notEmptyoperator - Use
toLowerfor case-insensitive comparison - Use
trimoperator to remove whitespace - Verify variable mapping path is correct
Can't access nested properties
Can't access nested properties
Possible causes:
- Variable mapping didn’t extract nested value
- Fact contains full object instead of specific property
- Use JSONPath in variable mapping to extract specific property:
$.step.output.nested.property - If fact contains object, use
jPathoperator in condition to access nested value - Consider using Map step before Condition to flatten data
Tips for Better Conditions
1
Map facts carefully
Use variable mapping to extract exactly the values you need. Make facts simple values when possible.
2
Start simple
Begin with basic conditions. Add complexity only when needed.
3
Use structured agent output
Define output schemas on agents for clean, predictable routing decisions.
4
Test all paths
Test each branch with appropriate test data to verify routing works correctly.
5
Handle null values
Always check for null/empty before comparing values using
notEmpty or isEmpty.6
Consider Rules + Condition
For complex logic, use Rules step to calculate, then Condition step to route based on results.