Condition Node
The Condition node is a crucial component in the Sequential Agents workflow, allowing for conditional branching based on various criteria. It evaluates conditions and determines which path the flow should take next.
Node Details
-
Name:
seqCondition
-
Label: Condition
-
Version: 2.0
-
Type: Condition
-
Category: Sequential Agents
Input Parameters
-
Condition Name (optional)
-
Type: string
-
Description: A descriptive name for the condition (e.g., “If X, then Y”)
-
-
Start | Agent | LLM | Tool Node (required)
-
Type: Start | Agent | LLMNode | ToolNode
-
Description: List of predecessor nodes in the sequential flow
-
-
Condition (required)
-
Type: conditionFunction
-
Description: The actual condition logic, which can be defined using either a table-based UI or custom JavaScript code
-
Condition Input Modes
Table-based UI
-
Allows defining conditions using a data grid with the following columns:
-
Variable: The value to check (e.g., message content, flow state, custom variables)
-
Operation: Comparison operation (e.g., Contains, Is Empty, Greater Than)
-
Value: The value to compare against
-
Output: The name of the output to trigger if the condition is met
-
Custom JavaScript
-
Allows writing a custom JavaScript function to evaluate conditions
-
Has access to flow state, messages, and custom variables
-
Must return a string value indicating the next step (e.g., “Agent” or “End”)
Outputs
-
Next
-
Type: Condition
-
Description: Connection point for the next node if a condition is met
-
-
End
-
Type: Condition
-
Description: Connection point to end the flow if no conditions are met
-
Functionality
-
The node evaluates conditions based on the current flow state, including:
-
Message history
-
Custom variables
-
Flow configuration (sessionId, chatId, etc.)
-
-
It determines the next step in the sequential flow based on the evaluation results
-
Supports complex decision-making logic through custom JavaScript functions
-
Allows for dynamic routing of the flow based on runtime conditions
Use Cases
-
Implementing decision trees in conversational flows
-
Routing conversations to different agents or tools based on user input
-
Ending conversations when certain conditions are met
-
Implementing loop logic or state-based transitions in sequential workflows
Implementation Details
-
Uses a sandbox environment to safely execute custom JavaScript code
-
Supports accessing and manipulating flow state and variables
-
Integrates with the broader Sequential Agents frameworks
Best Practices
-
Use descriptive condition names for better readability
-
Prefer the table-based UI for simple conditions
-
Use custom JavaScript for complex logic or when accessing specific parts of the flow state
-
Ensure custom functions always return a string value
-
Handle potential errors in custom code to avoid breaking the flow