WarpBuild LogoWarpBuild Docs
Control Nodes

If Node

Conditional branching node that executes different paths based on true/false evaluation

If Node

The If node provides conditional branching in your workflows. It evaluates a boolean condition and executes different sets of nodes based on whether the condition is true or false.

Configuration

Input Schema

FieldTypeRequiredDescription
ifbooleanYesThe boolean condition to evaluate
thenstring[]YesArray of node IDs to execute if condition is true
elsestring[]YesArray of node IDs to execute if condition is false

Output Schema

FieldTypeDescription
outputbooleanThe evaluated condition value

Basic Usage

# Simple condition check
- id: user_check
  type: condition
  input:
    if: "{{ user.isPremium }}"
    then: ["premium_features"]
    else: ["upgrade_prompt"]

Advanced Examples

# API response validation
- id: validate_response
  type: condition
  input:
    if: "{{ api_response.status === 200 }}"
    then: ["process_data", "save_result"]
    else: ["log_error", "retry_request", "notify_admin"]

Handle API responses gracefully by checking status codes and routing to appropriate error handling or success flows.

# Environment-based routing
- id: feature_toggle
  type: condition
  input:
    if: "{{ env.FEATURE_ENABLED && user.betaAccess }}"
    then: ["new_feature_flow"]
    else: ["legacy_feature_flow"]

Control feature rollout by combining environment variables with user permissions for gradual feature deployment.

# Input validation
- id: validate_input
  type: condition
  input:
    if: "{{ data.email && data.email.includes('@') }}"
    then: ["send_email", "log_success"]
    else: ["validation_error", "request_correction"]

Validate user input before processing to ensure data integrity and provide appropriate feedback for invalid inputs.

Integration Patterns

With HTTP Nodes

- id: api_call
  type: http
  input:
    url: "https://api.example.com/data"
    method: "GET"

- id: response_check
  type: condition
  input:
    if: "{{ api_call.output.ok }}"
    then: ["parse_response"]
    else: ["retry_api_call"]

With AI Nodes

- id: content_check
  type: condition
  input:
    if: "{{ content.length > 1000 }}"
    then: ["ai_summarize"]
    else: ["direct_process"]

With Loop Nodes

- id: batch_check
  type: condition
  input:
    if: "{{ items.length > 10 }}"
    then: ["batch_process_loop"]
    else: ["single_process"]

Troubleshooting

Debugging Tips

# Add debug logging
- id: debug_condition
  type: condition
  input:
    if: "{{ debug.log(user.status) || user.status === 'active' }}"
    then: ["log_true_path", "active_user_flow"]
    else: ["log_false_path", "inactive_user_flow"]

The If node is fundamental to creating intelligent, responsive workflows that adapt to different conditions and scenarios.

Last updated on