Skip to main content

Choice

1. Overview

The Choice component (choice) is a conditional branch inside the flow: it tests a condition and, depending on the result, routes execution down one path ("when") or another ("otherwise"). It's the equivalent of an "if/else" inside the automation.

Use it when the flow needs to make different decisions depending on the data received — for example, following one path if the customer is VIP and another otherwise.

Not suited for repeating an action multiple times (use the ForEach component for that) or when the decision logic is only meant to handle errors (each component has its own error-handling mechanisms).

2. Prerequisites

No credentials, licenses, or access to external systems. It's an internal component of the flow engine.

3. Authentication and Connection

Not applicable.

4. Configuration / Supported Operations

Choice has a single operation: evaluate a condition and run one of the two configured paths.

FieldRequiredTypeDescriptionExample
conditionYesText (expression)Condition to be evaluated. If true, the when path runs; if false, the otherwise path runs.order.amount > 1000
whenYesSub-flow (list of components)Sequence of steps run when the condition is true.A step that applies a special discount
otherwiseYesSub-flow (list of components)Sequence of steps run when the condition is false.A step that follows the default flow

Error behavior: if condition isn't informed or is empty, the flow fails at the build stage (before it even runs), with the error "Condition should be defined".

5. Practical Examples

Simple example: an order-approval flow uses Choice to check whether the order amount exceeds a limit. If so, the when path routes the order to manual approval; otherwise, the otherwise path approves it automatically.

Input:

{
"order": { "id": 981, "amount": 2500 }
}

Component configuration:

{
"componentName": "choice",
"configurations": {
"condition": "body.order.amount > 1000",
"when": {
"componentName": "add-variable",
"configurations": { "variables": { "status": "\"PENDING_APPROVAL\"" } }
},
"otherwise": {
"componentName": "add-variable",
"configurations": { "variables": { "status": "\"AUTO_APPROVED\"" } }
}
}
}

Response (in this case the amount is greater than 1000, so the when path ran):

{
"order": { "id": 981, "amount": 2500 },
"variables": { "status": "PENDING_APPROVAL" }
}

Advanced example: the condition combines more than one criterion — for example, order amount above a limit AND customer with no purchase history. Each path (when and otherwise) can in turn contain several chained components, including another nested Choice, allowing more complex decision trees.

Input:

{
"order": { "id": 982, "amount": 3000 },
"customer": { "totalPreviousOrders": 0 }
}

Component configuration:

{
"componentName": "choice",
"configurations": {
"condition": "body.order.amount > 1000 && body.customer.totalPreviousOrders == 0",
"when": {
"componentName": "add-variable",
"configurations": { "variables": { "status": "\"MANUAL_REVIEW\"" } }
},
"otherwise": {
"componentName": "add-variable",
"configurations": { "variables": { "status": "\"AUTO_APPROVED\"" } }
}
}
}

Response:

{
"order": { "id": 982, "amount": 3000 },
"customer": { "totalPreviousOrders": 0 },
"variables": { "status": "MANUAL_REVIEW" }
}

6. Common Errors and Troubleshooting

Error / SymptomLikely CauseHow to Fix
"Condition should be defined"The condition field wasn't filled in or is empty.Fill in the condition on the Choice component.
Flow always takes the same pathThe condition is always evaluating to the same result (true or false).Review the condition expression and the data it uses.
Error building the flow (when when or otherwise are malformed)The sub-flow structure configured in when/otherwise is incorrect.Validate that the components inside when and otherwise are configured correctly.

The condition field uses the MVEL expression language syntax, the same one used for rules and calculations elsewhere in the platform.