Skip to content

Conditional Flow

If Else Tool

Route flow based on conditions using natural language logic.

💡 Important: For complex data structures or when working with nested JSON, use the Parser Flow first to extract and structure your data before applying conditional logic. This ensures clean, accessible data for condition evaluation.

How to Use

Input Requirements

To set up conditional routing, you need:

  • Custom Prompt: Natural language description for evaluation
  • Condition: The logical statement to evaluate
  • Expected Value: What the condition should equal

How It Works

The conditional flow evaluates your natural language condition and routes the flow based on whether it matches your expected value.

Flow Logic:

  • If Condition equals Expected Value → Route to True path
  • If Condition does NOT equal Expected Value → Route to False path

Configuration Examples

User Permission Check

Custom Prompt: "Check if user has admin privileges" Condition: user.role === "admin"True Expected Value: True

Result:

  • ✅ If user is admin → Continue to True path
  • ❌ If user is not admin → Route to False path

Price Threshold Check

Custom Prompt: "Check if Bitcoin price is above $50,000" Condition: bitcoin_price > 50000True Expected Value: True

Result:

  • ✅ If Bitcoin > $50,000 → Execute buy orders (True path)
  • ❌ If Bitcoin ≤ $50,000 → Wait for better price (False path)

Account Balance Validation

Custom Prompt: "Verify user has sufficient balance for transaction" Condition: account_balance >= transaction_amountFalse Expected Value: True

Result:

  • ❌ Insufficient balance → Route to False path (decline transaction)
  • ✅ Sufficient balance → Route to True path (process transaction)

Time-based Conditions

Custom Prompt: "Check if current time is during business hours" Condition: current_hour >= 9 && current_hour <= 17True Expected Value: True

Result:

  • ✅ During business hours → Process request immediately (True path)
  • ❌ Outside business hours → Queue for next day (False path)

Natural Language Conditions

Simple Comparisons

  • "Is user age greater than 18"
  • "Does email contain @ symbol"
  • "Is order status equal to completed"
  • "Has user verified their account"

Complex Logic

  • "User has premium subscription AND account is active"
  • "Temperature is above 80 OR humidity is below 30"
  • "Order total exceeds $100 AND customer is VIP"
  • "File size is under 10MB AND format is PDF"

Status Checks

  • "Is API response successful"
  • "Has payment been processed"
  • "Are all required fields filled"
  • "Is inventory level sufficient"

Input Format

Describe conditions in plain English:

Example inputs:
  • "Check if user subscription is active"
  • "Verify if order total exceeds minimum"
  • "Confirm if file upload is complete"
  • "Validate if all permissions are granted"

Output Routing

Based on condition evaluation:

True Path: Condition matches expected value

  • Continue with primary workflow
  • Execute success actions
  • Proceed to next steps

False Path: Condition does not match expected value

  • Handle alternative scenario
  • Execute fallback actions
  • Route to error handling

Data Preprocessing with Parser Flow

For optimal results, especially with complex JSON structures, preprocess your data using the Parser Flow:

When to Use Parser First

  • Complex nested JSON: Multiple levels of object nesting
  • Array data: When you need specific array elements
  • Mixed data types: When original message contains various formats
  • Field extraction: When you need specific fields from large JSON objects

Example: User Data Processing

Step 1 - Parser Flow:

// Original message (complex user object)
{
  "response": {
    "user": {
      "profile": {
        "subscription": {
          "tier": "premium",
          "active": true,
          "expires": "2024-12-31"
        }
      }
    }
  }
}
 
// Parser extracts: response.user.profile.subscription.active
// Result: true

Step 2 - Conditional Flow:

Condition: "subscription status is active"
Input: true (from Parser)
Expected Value: true
Result: Routes to True path

Example: API Response Processing

Step 1 - Parser Flow:

// Original API response
{
  "status": "success",
  "data": {
    "orders": [
      {"id": 1, "total": 150.00, "status": "completed"},
      {"id": 2, "total": 75.50, "status": "pending"}
    ]
  }
}
 
// Parser extracts: data.orders[0].total
// Result: 150.00

Step 2 - Conditional Flow:

Condition: "order total exceeds minimum purchase"
Input: 150.00 (from Parser)
Expected Value: true (for amounts > 100)
Result: Routes to True path

Extracting Original Message After Conditional

The Conditional flow preserves the original message in its output for further processing:

Conditional Flow Output:

{
  "result": true,
  "next": 1,
  "reasoning": "Order total of 150.00 exceeds minimum purchase requirement",
  "extracted_value": 150.00,
  "condition": "order total exceeds minimum purchase",
  "expected_value": true,
  "originalMessage": "{\"status\":\"success\",\"data\":{\"orders\":[...]}}"
}

Step 3 - Extract Original Message with Parser:

Parser Path: originalMessage
Result: Full original JSON data available for further processing

This allows you to:

  • Route based on conditions (True/False paths)
  • Still access complete original data in subsequent flows
  • Process different parts of the original message based on routing

Use Cases

Authentication & Authorization

  • User login verification
  • Permission level checks
  • Access control validation
  • Session expiry checks

Business Logic

  • Pricing tier validation
  • Inventory availability
  • Payment processing approval
  • Subscription status verification

Data Validation

  • Form field completion
  • File format verification
  • Data quality checks
  • Input sanitization

Workflow Control

  • Process step completion
  • Resource availability
  • Time-based routing
  • Load balancing decisions

Configuration Tips

Setting Conditions

  1. Write clear, specific conditions
  2. Use exact values for comparison
  3. Consider edge cases
  4. Test both True and False paths

Expected Values

  • True: When you want the condition to be met
  • False: When you want the condition to fail or be opposite

Custom Prompts

  • Be descriptive and clear
  • Include context for evaluation
  • Specify exactly what to check
  • Use business-friendly language

Preserving Original Data

  • Conditional flow always includes originalMessage in output
  • Use Parser flow after Conditional to extract originalMessage
  • This enables access to full original data in subsequent flows
  • Essential for workflows that need both routing logic AND original data processing

Common Patterns

Gate Keeper Pattern

Condition: "User has required permissions"
Expected: True
True Path: → Grant access
False Path: → Deny access

Circuit Breaker Pattern

Condition: "System load is under threshold"  
Expected: True
True Path: → Process request
False Path: → Queue or reject

Feature Flag Pattern

Condition: "Feature X is enabled for user"
Expected: True  
True Path: → Show new feature
False Path: → Show legacy feature

Best Practices

  • Clear Conditions: Write conditions that are easy to understand
  • Test Both Paths: Ensure both True and False routes work correctly
  • Handle Edge Cases: Consider what happens with null or unexpected values
  • Document Logic: Use descriptive custom prompts
  • Keep It Simple: Avoid overly complex nested conditions

Getting Help

For questions about setting up conditional logic or troubleshooting routing issues, contact support for assistance.