Knowledge Base

Nodes

Understanding the Condition Node in AgentRunner

Using the Condition Node

Alexandra Nagy image Written by Alexandra Nagy
Back to articles Alexandra Nagy image Written by Alexandra Nagy

This article explains how to use the Condition node in AgentRunner to create conditional logic within your agents. The Condition node functions like an "if-else" statement in programming, allowing you to compare values and direct your agent's flow based on the outcome of the comparison.

What is the Condition Node?

The Condition node is a fundamental building block for creating dynamic and responsive agents within AgentRunner. It enables your agent to make decisions based on input data, allowing it to follow different paths or execute specific actions based on whether a condition is met. This is crucial for creating agents that can handle various scenarios and provide personalized experiences. The Condition node compares an input value against a comparison value based on a specified condition. The result of this comparison (true or false) can then be used to determine the next step in your agent's workflow.

Input and Comparison Values

The Condition node requires two primary inputs for its comparison: the input value and the comparison value.

  • Input Value: This is the value you want to evaluate. It can be:

    • The output of another node in your agent's workflow.

    • A direct input from an Input node (e.g., user input, data from an external API).

    • The input value is always treated as text.

  • Comparison Value: This is the value you're comparing the input value against. It can be:

    • A fixed text string that you enter directly into the Condition node.

    • The output of another node in your agent's workflow.

    • A direct input from an Input node.

    • The comparison value is always treated as text.

Available Conditions

The Condition node supports a variety of comparison operators, allowing you to perform different types of evaluations:

  • contains: Returns true if the input value includes the comparison value as a substring.

  • not contains: Returns true if the input value does not include the comparison value as a substring.

  • starts with: Returns true if the input value begins with the comparison value.

  • ends with: Returns true if the input value terminates with the comparison value.

  • is: Returns true if the input value is exactly the same as the comparison value.

  • is not: Returns true if the input value is not exactly the same as the comparison value.

  • is empty: Returns true if the input value is empty.

  • is not empty: Returns true if the input value is not empty.

    All comparisons are case sensitive.

How to Use the Condition Node

This section walks you through the steps to use the Condition node effectively within AgentRunner.

Step-by-Step Instructions

  1. Add a Condition Node: Drag and drop a Condition node from the node library onto your agent's canvas.

  2. Connect the Input Value: Connect the output of the node that provides the input value to the input of the Condition node labeled "Input Value." This could be an Input node (collecting user input) or the output of another processing node.

  3. Define the Comparison Value: Determine the source of your comparison value. You can either:

    • Connect the output of another node to the input of the Condition node labeled "Comparison Value."

    • Enter a fixed text string directly into the "Comparison Value" field within the Condition node's settings.

  4. Select the Condition: Choose the appropriate condition from the dropdown menu within the Condition node's settings. Select the condition that best suits your comparison needs (e.g., "contains," "is," "starts with").

  5. Connect the Output Paths: The Condition node has two output paths: "True" and "False." Connect the "True" path to the node(s) you want to execute if the condition is met. Connect the "False" path to the node(s) you want to execute if the condition is not met.

  6. Test Your Agent: Run your agent with different input values to ensure the Condition node is behaving as expected and directing the flow correctly.

Example Scenario: Checking for a Keyword

Let's say you want your agent to respond differently based on whether a user's input contains the word "help."

  1. Add an Input node to capture the user's input.

  2. Add a Condition node.

  3. Connect the output of the Input node to the "Input Value" of the Condition node.

  4. In the Condition node's settings, set the "Comparison Value" to "help".

  5. Select the "contains" condition.

  6. Connect the "True" path to a node that provides help information.

  7. Connect the "False" path to a node that handles normal conversation.

Now, if the user's input contains the word "help," the agent will provide help information; otherwise, it will continue with the regular conversation flow.

Important Considerations

  • Data Types: All input and comparison values are treated as text strings.

  • Case Sensitivity: Comparisons are case-sensitive. The "is," "is not", "contains", "not contains", "starts with", and "ends with" conditions will differentiate between uppercase and lowercase letters.

  • Null Values: The input and comparison values cannot be null or undefined. The agent will return an error if either value is missing.

  • Regular Expressions: The Condition node does not directly support regular expressions. However, you can achieve similar results by stacking multiple Condition nodes to create more complex pattern matching logic.

  • JSON Objects: If the Input Value or Comparison Value is a JSON object, it will be treated as a normal string text.

By understanding and utilizing the Condition node effectively, you can build sophisticated agents that respond intelligently to different inputs and scenarios within AgentRunner.

Did this answer your question?

Sad smiley Neutral smiley Happy smiley
AI-Powered Knowledge Base by

2025