
Overview
The If-Else block evaluates a Python expression and routes workflow execution to either a True or False branch based on the result. Use it to create conditional logic in your blueprints, enabling different actions based on data conditions. The expression must be a single Python expression that evaluates to a Boolean value. You can use variables, comparison operators, logical operators, and built-in Python functions in your expression.Common use cases
- Validating user input before processing
- Checking if data meets specific criteria
- Routing workflows based on configuration settings
- Implementing business rules and decision logic
- Verifying API responses or data availability
How it works
- Expression: Enter a Python expression that evaluates to
TrueorFalse. The expression must be a single expression, not multiple statements. - Evaluation: The block evaluates the expression using the Python interpreter.
- Routing: Based on the result:
- If the expression evaluates to
True, the workflow continues to the True branch - If the expression evaluates to
False, the workflow continues to the False branch - If an error occurs during evaluation, the workflow continues to the Error branch
- If the expression evaluates to
Expression examples
Examples
Data quality validation
This example shows how to validate API response data before processing it further in the workflow. Blueprint Flow:- HTTP Request → Fetches data from external API
- If-Else → Validates response contains required fields 3a. True branch → Text generation → Processes valid data 3b. False branch → Log message → Records validation failure
- Expression:
isinstance(result, dict) and "data" in result and len(result["data"]) > 0
Score-based routing
This example demonstrates routing users to different workflows based on their performance score. Blueprint Flow:- UI Trigger → User completes assessment
- Python code → Calculates total score
- If-Else → Checks if score meets passing threshold 4a. True branch → Text generation → Generates certificate 4b. False branch → Text generation → Generates improvement recommendations
- Expression:
state["total_score"] >= state["passing_threshold"]
Fields
| Name | Type | Control | Default | Description | Options | Validation |
|---|---|---|---|---|---|---|
| Expression | Eval | - | - | The expression to be evaluated. Must be a single expression (no statements). | - | - |
End states
Below are the possible end states of the block call.| Name | Field | Type | Description |
|---|---|---|---|
| True | - | success | The event handler execution for True. |
| False | - | success | The event handler execution for False. |
| Error | - | error | The expression evaluation failed. |