Overview

If/Else statements create decision points in your workflow. They evaluate a condition and direct your agent down different paths based on whether that condition is true or false.

Use Cases

  • Create branching workflows based on user inputs or data values
  • Implement decision logic to handle different scenarios
  • Personalize responses to different types of users
  • Apply different processing based on data characteristics

How to Use If/Else Statements

Step 1: Add the Action

  1. In your agent’s Actions tab, click “Add action”
  2. Select the “If/Else Statement” option

Step 2: Configure the First Condition

  1. Leave the “Is Else Statement?” checkbox unchecked for your first condition
  2. Enter your condition in the field 
  3. Add the actions you want to run when this condition is TRUE

Writing Conditions

Conditions must evaluate to true or false. Common formats include:

  • Comparing numbers: variable > 100
  • Checking equality: variable == “specific value”
  • Multiple conditions: variable1 > 10 && variable2 == “active”

Step 3: Add Additional Paths (Else If)

  1. Add another “If/Else Statement” action
  2. Check the “Is Else Statement?” checkbox to connect it to the previous condition
  3. Enter your next condition
  4. Add the actions you want to run when this condition is TRUE
  5. Repeat this step to add as many alternative paths as needed

Step 4: Add a Default Path (Else)

  1. Add an “If/Else Statement” action after your other conditions
  2. Check the “Is Else Statement?” checkbox
  3. Leave the Conditional Statement field blank
  4. Add the actions to run when no other conditions are met

Step 5: End the Statement

  1. After all your conditional paths, add the “End If/Else/For Statement” action

Example: IF/ELSE Example Agent

See this simple example agent to learn how to use If/Else statements:

  1. We collect a budget amount from the user
  2. We evaluate three budget ranges
  3. Each path provides different output based on the budget amount