Skip to main content

IF Node Guide

Overview

The IF Node is a conditional control flow component that enables dynamic branching in your workflows based on data evaluation. It assesses conditions against input data and determines which path the workflow should follow next, allowing for sophisticated decision-making capabilities within your automation processes.

Use Cases

  • Implementing business logic rules (e.g., determining eligibility based on multiple criteria)
  • Filtering data based on specific attributes
  • Creating conditional notification paths (e.g., alert only for high-severity findings)
  • Implementing feature flags and conditional functionality
  • Validating input data before proceeding with processing
  • Creating different processing branches based on data characteristics
  • Implementing complex multi-step decision trees

Creating an IF Node

Basic Setup

  1. Drag an IF Node from the node palette onto your workflow canvas
  2. Connect it to one or more input nodes that provide the data to evaluate
  3. Configure condition groups and the combine operator
  4. Create outgoing connections with appropriate edge types (true/false) to downstream nodes

IF Node being added to a workflow

Condition Configuration

Configuring an IF node involves setting up conditions that will be evaluated against incoming data:

  1. In the node configuration panel, add one or more condition groups
  2. For each group, set the logical operator (AND/OR) to combine conditions within the group
  3. Add individual conditions to each group
  4. Set the top-level combine operator to determine how group results are combined
  5. Connect true/false edges to appropriate downstream nodes

IF Node Condition configuration interface

Configuration Options

Node Properties

PropertyDescription
NameA descriptive name for the node
Input TypeThe type of input data (usually "json")
Output TypeThe type of output data (usually "json")
Condition GroupsGroups of conditions to evaluate
Combine OperatorLogical operator (AND/OR) to combine group results

Condition Properties

PropertyDescription
Left ValueJSONPath expression or value to evaluate (e.g., $.user.age)
Comparison TypeType of comparison (equals, not_equals, contains, etc.)
Right ValueValue or JSONPath expression to compare against
Value TypeData type for comparison (string, number, boolean)

Supported Comparison Types

The IF node supports these comparison types:

ComparisonDescriptionExample
EqualsChecks if values are equal$.status = "active"
Not EqualsChecks if values are not equal$.status != "inactive"
ContainsChecks if a string contains another string$.email contains "@company.com"
Greater ThanChecks if left value is greater than right value$.age > 18
Less ThanChecks if left value is less than right value$.score < 100
RegexChecks if left value matches a regex pattern$.email matches "^.+@gmail\.com$"
EmptyChecks if a value is empty (null/empty string/array/object)$.tags is empty
Not EmptyChecks if a value is not empty$.tags is not empty

Condition Grouping

The IF node supports a hierarchical condition structure with two levels of logical operations:

Group Level

  • Multiple conditions within a group are combined using the group's operator (AND/OR)
  • Use AND when all conditions must be true
  • Use OR when any condition can be true

Node Level

  • Multiple condition groups are combined using the top-level combine operator (AND/OR)
  • Use AND when all groups must evaluate to true
  • Use OR when any group can evaluate to true

How IF Nodes Work

When a workflow is executed:

  1. The IF Node receives input data from upstream nodes
  2. JSONPath expressions in conditions are resolved against the input data
  3. Each condition is evaluated based on its comparison type and resolved values
  4. Condition results are combined using the group operator (AND/OR)
  5. Group results are combined using the combine operator (AND/OR)
  6. The final boolean result (true/false) determines which branch to follow
  7. The node writes detailed evaluation results to its output
  8. Downstream nodes connected with the appropriate edge type (true/false) are executed

Evaluation Process Diagram

sequenceDiagram
participant Input as Input Data
participant IF as IF Node
participant True as True Branch
participant False as False Branch

Input->>IF: Provide data
IF->>IF: Evaluate conditions
IF->>IF: Combine results

alt Condition Result = True
IF->>True: Execute true branch
else Condition Result = False
IF->>False: Execute false branch
end

JSONPath Usage

The IF node uses JSONPath expressions to access data within the input JSON:

  • Basic property access: $.user.name
  • Array indexing: $.items[0].value
  • Multiple levels: $.data.users[0].profile.settings.notifications

Examples of JSONPath Expressions

$.customer.age                  // Access a simple property
$.orders[0].total // Access the first item in an array
$.products[*].price // Use wildcard to access all prices (returns array)
$.user.profile.address.city // Access deeply nested properties

Best Practices

Condition Design

  1. Order Conditions Efficiently:

    • Put low-cost conditions first in AND groups
    • Put high-probability conditions first in OR groups
  2. Use Appropriate Value Types:

    • Specify value_type as "string", "number", or "boolean"
    • This ensures proper comparison semantics
  3. Handle Missing Data:

    • Use the empty and not_empty comparison types to check existence
    • Add validation conditions before accessing nested properties

Condition Grouping

  1. Logical Organization:

    • Group related conditions that naturally belong together
    • Use AND for conditions that all must be true together
    • Use OR for alternative conditions
  2. Complex Logic Implementation:

    • To implement "A AND (B OR C)":
      • Create a group for A with AND operator
      • Create another group for B and C with OR operator
      • Use AND as the combine operator
    • To implement "(A AND B) OR (C AND D)":
      • Create a group for A and B with AND operator
      • Create another group for C and D with AND operator
      • Use OR as the combine operator

Example Configurations

Example 1: Simple Age Verification

Evaluates if a user is over 18 years old.

{
"condition_groups": [
{
"id": "group1",
"conditions": [
{
"id": "condition1",
"left_value": "$.user.age",
"comparison_type": "greater_than",
"right_value": "18",
"value_type": "number"
}
],
"operator": "and"
}
],
"combine_operator": "and"
}

Input Data:

{
"user": {
"id": 12345,
"name": "John Doe",
"age": 25,
"email": "[email protected]"
}
}

Example 2: Premium Customer Qualification

This example checks if a customer is premium either by:

  1. Having total purchases > $1000 AND account age > 365 days, OR
  2. Having "platinum" VIP status
{
"condition_groups": [
{
"id": "group1",
"operator": "and",
"conditions": [
{
"id": "cond1",
"left_value": "$.customer.totalPurchases",
"comparison_type": "greater_than",
"right_value": "1000",
"value_type": "number"
},
{
"id": "cond2",
"left_value": "$.customer.accountAge",
"comparison_type": "greater_than",
"right_value": "365",
"value_type": "number"
}
]
},
{
"id": "group2",
"operator": "and",
"conditions": [
{
"id": "cond3",
"left_value": "$.customer.vipStatus",
"comparison_type": "equals",
"right_value": "platinum",
"value_type": "string"
}
]
}
],
"combine_operator": "or"
}

Example 3: Input Validation

Checks if essential data is present before processing:

{
"condition_groups": [
{
"id": "validation",
"operator": "and",
"conditions": [
{
"id": "check1",
"left_value": "$.apiKey",
"comparison_type": "not_empty"
},
{
"id": "check2",
"left_value": "$.target",
"comparison_type": "not_empty"
},
{
"id": "check3",
"left_value": "$.options",
"comparison_type": "not_empty"
}
]
}
],
"combine_operator": "and"
}

Troubleshooting

IssueResolution
Condition not evaluating as expectedCheck the value types and ensure proper comparison type is used
JSONPath not resolvingVerify the path exists in your input data and check for typos
Missing fieldsVerify upstream nodes are providing the expected data structure
Type conversion failuresCheck if the data matches the specified value type

Working with Edge Types

The IF node relies on edge types to determine which downstream nodes should execute:

Edge Types for IF Nodes

  • True Edge: Connect this edge to nodes that should execute when the condition is true
  • False Edge: Connect this edge to nodes that should execute when the condition is false

To configure an edge type, create a connection from the IF node's true/false edge to a downstream node

IF Node edges

Next Steps

After configuring your IF Node, you might want to:

  • Add different processing nodes in the true/false branches
  • Chain multiple IF nodes for complex decision trees
  • Use Script nodes to prepare data for condition evaluation

Complete workflow with IF Node and branching paths