Actions
If/Else Statement
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
- In your agent’s Actions tab, click “Add action”
- Select the “If/Else Statement” option
Step 2: Configure the First Condition
- Leave the “Is Else Statement?” checkbox unchecked for your first condition
- Enter your condition in the field
- 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)
- Add another “If/Else Statement” action
- Check the “Is Else Statement?” checkbox to connect it to the previous condition
- Enter your next condition
- Add the actions you want to run when this condition is TRUE
- Repeat this step to add as many alternative paths as needed
Step 4: Add a Default Path (Else)
- Add an “If/Else Statement” action after your other conditions
- Check the “Is Else Statement?” checkbox
- Leave the Conditional Statement field blank
- Add the actions to run when no other conditions are met
Step 5: End the Statement
- 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:
- We collect a budget amount from the user
- We evaluate three budget ranges
- Each path provides different output based on the budget amount