Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.optexity.com/llms.txt

Use this file to discover all available pages before exploring further.

Use if_else_node for conditional execution based on runtime conditions—handling different page states, optional elements, or branching logic. To determine condition logic, use extraction actions to capture data from the page and store it as variables. These variables are then referenced in if_else_node conditions to make branching decisions based on the extracted data.

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\")"
        }
      }
    }
  ]
}
Note: Variables like has_captcha are extracted from the page using an extraction action (see Using Extraction Nodes to Set Conditions below).

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)

Using Extraction Nodes to Set Conditions

Extraction nodes allow you to capture data from the page and store it as variables. These variables can then be referenced in if_else_node conditions to make branching decisions based on the extracted data.

How It Works

  1. Extract data using an extraction_action and specify output_variable_names to create a variable
  2. Reference the variable in an if_else_node condition using the syntax variable_name[0]
  3. Branch logic executes different paths based on the extracted value

Variable Naming and Syntax

  • Variables are referenced using array index syntax: variable_name[0]
  • The [0] accesses the first (or only) element of the extracted value
  • Multiple extractions create arrays: variable_name[0], variable_name[1], etc.

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

Extract and Check Page State

[
  {
    "type": "action_node",
    "extraction_action": {
      "llm": {
        "extraction_format": {
          "is_login_page": "bool"
        },
        "extraction_instructions": "Check if the current page is a login page asking for username or password. If yes, return 'is_login_page' as true, otherwise return false",
        "output_variable_names": [
          "is_login_page"
        ],
        "llm_model_name": "gemini-2.5-pro"
      }
    },
    "before_sleep_time": 3,
    "end_sleep_time": 0
  },
  {
    "type": "if_else_node",
    "condition": "is_login_page[0]",
    "if_nodes": [
      {
        "type": "action_node",
        "interaction_action": {
          "input_text": {
            "command": "get_by_label(\"Username\")",
            "input_text": "{username[0]}"
          }
        }
      }
    ],
    "else_nodes": [
      {
        "type": "action_node",
        "interaction_action": {
          "click_element": {
            "command": "get_by_role(\"button\", name=\"Next\")"
          }
        }
      }
    ]
  }
]

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.