Skip to main content
Use if_else_node for conditional execution based on runtime conditions—handling different page states, optional elements, or branching logic.

Structure

{
  "type": "if_else_node",
  "condition": "has_captcha[0]",
  "if_nodes": [
    {
      "type": "action_node",
      "interaction_action": {
        "agentic_task": {
          "task": "Solve the captcha",
          "max_steps": 10,
          "backend": "browser_use"
        }
      }
    }
  ],
  "else_nodes": [
    {
      "type": "action_node",
      "interaction_action": {
        "click_element": {
          "command": "get_by_role(\"button\", name=\"Continue\")"
        }
      }
    }
  ]
}

Properties

PropertyTypeDescription
conditionstrPython-like expression to evaluate
if_nodeslist[action_node | if_else_node | for_loop_node]Actions when condition is true
else_nodeslist[...]Actions when condition is false (optional)

Condition Syntax

Conditions are Python-like expressions that can reference parameters:
{
  "condition": "is_login_screen[0]"
}
{
  "condition": "has_2fa[0] == 'true'"
}
{
  "condition": "verification_needed[0] is not None and verification_needed[0] != 'skip'"
}

Operators

OperatorExample
Equalityvar[0] == 'value'
Inequalityvar[0] != 'value'
None checkvar[0] is not None
Booleanvar[0] == 'true'
Logical ANDa[0] == 'x' and b[0] == 'y'
Logical ORa[0] == 'x' or b[0] == 'y'

Examples

Handle Optional 2FA

{
  "type": "if_else_node",
  "condition": "requires_2fa[0] == 'true'",
  "if_nodes": [
    {
      "type": "action_node",
      "interaction_action": {
        "input_text": {
          "command": "get_by_label(\"Verification Code\")",
          "input_text": "{auth_code[0]}"
        }
      }
    }
  ],
  "else_nodes": []
}

Branch Based on Extracted Value

[
  {
    "type": "action_node",
    "extraction_action": {
      "llm": {
        "extraction_format": { "status": "str" },
        "extraction_instructions": "Extract the order status",
        "output_variable_names": ["status"]
      }
    }
  },
  {
    "type": "if_else_node",
    "condition": "status[0] == 'pending'",
    "if_nodes": [
      {
        "type": "action_node",
        "interaction_action": {
          "click_element": {
            "command": "get_by_role(\"button\", name=\"Approve\")"
          }
        }
      }
    ],
    "else_nodes": []
  }
]

Nested Conditions

{
  "type": "if_else_node",
  "condition": "user_type[0] == 'admin'",
  "if_nodes": [
    {
      "type": "if_else_node",
      "condition": "access_level[0] == 'full'",
      "if_nodes": [ ... ],
      "else_nodes": [ ... ]
    }
  ],
  "else_nodes": []
}
else_nodes is optional. If omitted or empty, nothing happens when condition is false.