Enable dynamic workflow routing based on conditions, data comparisons, and logical evaluations
The handleConditional function enables dynamic workflow routing based on conditions, data comparisons, and logical evaluations. This powerful function allows your Vibes to make intelligent decisions and branch into different execution paths based on the data processed in previous steps.
- id: check_condition
function: handleConditional
input:
condition:
type: "if"
condition:
operator: "eq"
left: "${steps.status.output.value}"
right: "active"
then: "success_step"
else: "failure_step"Implements simple if/then/else logic with a single condition evaluation
- id: route_by_category
function: handleConditional
input:
condition:
type: "switch"
expression: "${steps.extract.output.category}"
cases:
- value: "urgent"
stepId: "urgent_handler"
- value: "normal"
stepId: "normal_handler"
default: "default_handler"Implements switch-case style routing with multiple possible outcomes
eqTests if two values are exactly equal
operator: "eq"
left: "${steps.status_check.output.status}"
right: "completed"neTests if two values are not equal
operator: "ne"
left: "${steps.result.output.error_count}"
right: 0gtTests if left value is numerically greater than right value
operator: "gt"
left: "${steps.calculate_total.output.amount}"
right: 1000gteTests if left value is greater than or equal to right value
operator: "gte"
left: "${steps.user_age.output.age}"
right: 18ltTests if left value is numerically less than right value
operator: "lt"
left: "${steps.inventory.output.stock_level}"
right: 10lteTests if left value is less than or equal to right value
operator: "lte"
left: "${steps.score.output.points}"
right: 50containsTests if left string contains the right string
operator: "contains"
left: "${steps.error_message.output.message}"
right: "timeout"startsWithTests if left string starts with the right string
operator: "startsWith"
left: "${steps.user_email.output.email}"
right: "admin"endsWithTests if left string ends with the right string
operator: "endsWith"
left: "${steps.filename.output.name}"
right: ".pdf"regexTests if left string matches the right regular expression pattern
operator: "regex"
left: "${steps.phone_number.output.number}"
right: "^\\+1\\d{10}$"existsTests if the value exists (is not null or undefined)
operator: "exists"
left: "${steps.user_profile.output.avatar_url}"isEmptyTests if the value is empty (null, undefined, empty string, empty array, or empty object)
operator: "isEmpty"
left: "${steps.search_results.output.results}"isNotEmptyTests if the value is not empty
operator: "isNotEmpty"
left: "${steps.validation_errors.output.errors}"andTests if all conditions in the array are true
operator: "and"
conditions:
- operator: "eq"
left: "${steps.status.output.active}"
right: true
- operator: "gt"
left: "${steps.balance.output.amount}"
right: 0orTests if any condition in the array is true
operator: "or"
conditions:
- operator: "eq"
left: "${steps.payment.output.method}"
right: "credit_card"
- operator: "eq"
left: "${steps.payment.output.method}"
right: "paypal"inTests if left value exists in the right array
operator: "in"
left: "${steps.user_role.output.role}"
right: ["admin", "moderator", "super_user"]Matches exact values (default behavior when no type is specified)
cases:
- value: "premium"
stepId: "premium_handler"
- value: "basic"
stepId: "basic_handler"Matches numeric values within a specified range
cases:
- type: "range"
min: 0
max: 10
stepId: "low_range_handler"
- type: "range"
min: 11
max: 100
stepId: "medium_range_handler"Matches string values using regular expressions
cases:
- type: "pattern"
pattern: "user_.*"
stepId: "user_handler"
- type: "pattern"
pattern: "admin_.*"
stepId: "admin_handler"Matches if the expression contains the specified substring
cases:
- type: "contains"
value: "error"
stepId: "error_handler"
- type: "contains"
value: "warning"
stepId: "warning_handler"Check user count and route to appropriate processing step
- id: check_user_count
function: handleConditional
input:
condition:
type: "if"
condition:
operator: "gt"
left: "${steps.fetch_users.output.count}"
right: 100
then: "process_large_dataset"
else: "process_small_dataset"Combine multiple conditions using AND logic to determine user flow
- id: check_multiple_conditions
function: handleConditional
input:
condition:
type: "if"
condition:
operator: "and"
conditions:
- operator: "eq"
left: "${steps.user_data.output.status}"
right: "active"
- operator: "gt"
left: "${steps.user_data.output.score}"
right: 80
then: "premium_user_flow"
else: "standard_user_flow"Route workflow based on priority level using switch-case logic
- id: route_by_priority
function: handleConditional
input:
condition:
type: "switch"
expression: "${steps.extract_priority.output.priority_level}"
cases:
- value: "high"
stepId: "urgent_processing"
- value: "medium"
stepId: "standard_processing"
- value: "low"
stepId: "batch_processing"
default: "error_handler"The queryKnowledgebase function returns structured document entries with citation information and content excerpts.
{
"next_step_id": "target_step_id",
"conditionResult": {
"type": "if" | "switch",
"evaluatedTo": "target_step_id",
"condition": { /* original condition object */ }
}
}${steps.previous_step.output.property_name}Reference output from previous steps
${global_variable_name}Reference global variables
${steps.data.output.user.profile.email}Access nested object properties
${steps.results.output.items[0].status}Access specific array elements
Direct workflows based on business rules and user roles
Choose processing paths based on data characteristics
Implement sophisticated error handling and recovery logic
Implement quality gates and approval processes