logo_smallAxellero.io

Branch

Route workflow execution based on conditional logic with multiple named branches.

The Branch node enables conditional routing in workflows by evaluating goval expressions against workflow context data. Each condition creates a separate output path, allowing complex decision logic and parallel execution paths.

┌─────────────────────────────────────────────────────────┐
│                   BRANCH EXECUTION                      │
├─────────────────────────────────────────────────────────┤
│                                                         │
│    ┌─────────┐                                          │
│    │ PREVIOUS│                                          │
│    │  NODE   │                                          │
│    └────┬────┘                                          │
│         │                                               │
│    ┌────▼────┐     ┌─────────┐     ┌─────────┐          │
│    │ BRANCH  │────▶│CONDITION│────▶│ NODE A  │          │
│    │  NODE   │     │    1    │     │         │          │
│    │         │     │(age>18) │     └─────────┘          │
│    │         │     └─────────┘                          │
│    │         │                                          │
│    │         │     ┌─────────┐     ┌─────────┐          │
│    │         │────▶│CONDITION│────▶│ NODE B  │          │
│    │         │     │    2    │     │         │          │
│    │         │     │(admin)  │     └─────────┘          │
│    │         │     └─────────┘                          │
│    │         │                                          │
│    │         │     ┌─────────┐     ┌─────────┐          │
│    │         │────▶│CONDITION│────▶│ NODE C  │          │
│    │         │     │    3    │     │         │          │
│    │         │     │(default)│     └─────────┘          │
│    └─────────┘     └─────────┘                          │
│                                                         │
└─────────────────────────────────────────────────────────┘

Configuration

PropertyValue
Codebranch
Workflow TypesWorkflow

Connections

DirectionDescription
IncomingSingle input connection from previous node
OutgoingMultiple outputs - one for each condition

Each condition creates a separate output handle with unique connection points for targeted routing.

Condition Management

Adding Conditions

  1. Create Condition: Click "Add Condition" to create a new branch
  2. Name Condition: Enter descriptive title for the condition
  3. Write Expression: Define goval expression that evaluates to boolean
  4. Connect Output: Link condition output to target node

Condition Structure

Each condition contains:

FieldPurposeExample
TitleHuman-readable branch name"Adult User"
ExpressionGoval boolean expressionctx.nodes.start.outputs.age > 18
Output HandleUnique connection pointcondition-{id}-source

Expression Syntax

Conditions use goval expressions with access to workflow context:

// Access node outputs
{{ctx.nodes.start.inputs.userType === "premium"}}

// Numeric comparisons
{{ctx.nodes.calculator.outputs.total > 1000}}

// String operations
{{ctx.nodes.userInfo.outputs.email.includes("@company.com")}}

// Boolean logic
{{ctx.nodes.auth.outputs.isActive && ctx.nodes.auth.outputs.role === "admin"}}

// Default fallback (always true)
{{true}}

Common Expression Patterns

User Authentication:

// Check user role
{{ctx.user.roles.includes("admin")}}

// Verify user permissions
{{ctx.user.attrs.department === "engineering"}}

Data Validation:

// Required field check
{{ctx.nodes.start.inputs.email && ctx.nodes.start.inputs.email !== ""}}

// Range validation
{{ctx.nodes.form.outputs.age >= 18 && ctx.nodes.form.outputs.age <= 65}}

// Format validation
{{ctx.nodes.input.outputs.phone.match(/^\+?[1-9]\d{1,14}$/)}}

Business Logic:

// Order processing
{{ctx.nodes.order.outputs.amount > 500 && ctx.nodes.customer.outputs.tier === "gold"}}

// Approval workflow
{{ctx.nodes.request.outputs.priority === "urgent" || ctx.nodes.manager.outputs.approved}}

// Error handling
{{!ctx.nodes.apiCall.error}}

Execution Flow

Condition Evaluation

  1. Sequential Processing: Conditions are evaluated in the order they appear
  2. Context Access: Each expression has access to complete workflow context
  3. Boolean Requirement: All expressions must evaluate to true or false
  4. Multiple Paths: Multiple conditions can be true simultaneously

Routing Logic

  • True Conditions: Workflow continues through connections of true conditions
  • False Conditions: No execution flows through false condition outputs
  • Parallel Execution: Multiple true conditions enable parallel workflow paths
  • All False Error: If all conditions evaluate to false, workflow fails with error

Error Scenarios

Error TypeCauseSolution
Non-boolean resultExpression returns non-boolean valueEnsure expression evaluates to true/false
All conditions falseNo conditions evaluate to trueAdd default condition or fix logic
Expression errorInvalid goval syntaxValidate expression syntax
Context access errorReferenced node/property doesn't existVerify workflow context paths

Branch Strategies

Exclusive Branching

Only one path should execute:

// Age-based routing (mutually exclusive)
Condition 1: {{ctx.nodes.start.inputs.age < 18}}        // "Minor"
Condition 2: {{ctx.nodes.start.inputs.age >= 18 && ctx.nodes.start.inputs.age < 65}}  // "Adult" 
Condition 3: {{ctx.nodes.start.inputs.age >= 65}}       // "Senior"

Inclusive Branching

Multiple paths can execute simultaneously:

// Multi-channel notification
Condition 1: {{ctx.nodes.user.outputs.emailEnabled}}    // "Email notification"
Condition 2: {{ctx.nodes.user.outputs.smsEnabled}}      // "SMS notification"  
Condition 3: {{ctx.nodes.user.outputs.pushEnabled}}     // "Push notification"

Default Fallback

Always include a catch-all condition:

// Priority handling with fallback
Condition 1: {{ctx.nodes.request.outputs.priority === "critical"}}  // "Critical path"
Condition 2: {{ctx.nodes.request.outputs.priority === "high"}}      // "High priority"
Condition 3: {{true}}                                               // "Standard processing"

Advanced Features

Dynamic Condition Values

Access dynamic data from previous nodes:

// Dynamic threshold from configuration
{{ctx.nodes.settings.outputs.threshold > ctx.nodes.data.outputs.value}}

// User-specific limits
{{ctx.nodes.calculation.outputs.amount <= ctx.user.attrs.creditLimit}}

Complex Boolean Logic

Combine multiple conditions with logical operators:

// Multi-factor authentication
{{(ctx.nodes.auth.outputs.passwordValid && ctx.nodes.auth.outputs.mfaEnabled) || ctx.user.roles.includes("trusted")}}

// Business hours check with override
{{(ctx.nodes.timeCheck.outputs.isBusinessHours && ctx.nodes.request.outputs.standard) || ctx.nodes.request.outputs.emergency}}

Error Recovery Patterns

Handle errors gracefully in branch conditions:

// Safe property access
{{ctx.nodes.api.outputs.data && ctx.nodes.api.outputs.data.status === "success"}}

// Error branching
{{ctx.nodes.processor.error}}  // "Error handling path"
{{!ctx.nodes.processor.error}} // "Success path"

Best Practices

Condition Design

  • Descriptive Titles: Use clear, meaningful condition names
  • Simple Logic: Keep expressions readable and maintainable
  • Defensive Programming: Handle null/undefined values safely
  • Test Thoroughly: Verify all condition paths with test data

Performance Considerations

  • Efficient Expressions: Avoid complex computations in conditions
  • Context Optimization: Access only necessary context properties
  • Minimize Conditions: Use fewest conditions needed for logic
  • Order Matters: Place most likely conditions first for readability

Error Prevention

  • Default Paths: Always include fallback conditions
  • Validation: Validate required data exists before evaluation
  • Type Safety: Ensure consistent data types in comparisons
  • Documentation: Document complex business logic

Troubleshooting

Common Issues

ProblemSymptomsSolution
Branch doesn't executeNo output connections triggerCheck condition expressions return boolean
All paths fail"All conditions false" errorAdd default condition with {{true}}
Unexpected routingWrong path executesReview condition logic and test with sample data
Expression errorsNode fails during executionValidate goval syntax and context paths

Debugging Techniques

  1. Test Individual Conditions: Use node testing to verify condition results
  2. Check Context Access: Verify referenced nodes and properties exist
  3. Simplify Logic: Break complex conditions into smaller parts
  4. Add Logging: Use subsequent nodes to log condition results
  5. Review Execution: Check workflow execution logs for branch outcomes

Examples

User Permission Routing

// Route based on user roles and permissions
Branch Node: "Permission Check"

Condition 1: "Admin Access"
Expression: {{ctx.user.roles.includes("admin")}}
→ Connects to: Admin Dashboard Node

Condition 2: "Manager Access" 
Expression: {{ctx.user.roles.includes("manager") && ctx.user.attrs.department === "sales"}}
→ Connects to: Manager Tools Node

Condition 3: "Standard User"
Expression: {{true}}
→ Connects to: User Portal Node

Order Processing Workflow

// E-commerce order routing
Branch Node: "Order Classification"

Condition 1: "Express Processing"
Expression: {{ctx.nodes.order.outputs.total > 100 && ctx.nodes.customer.outputs.isPremium}}
→ Connects to: Express Fulfillment Node

Condition 2: "Standard Processing"
Expression: {{ctx.nodes.order.outputs.total > 25}}
→ Connects to: Standard Fulfillment Node

Condition 3: "Manual Review"
Expression: {{true}}
→ Connects to: Review Queue Node

API Response Handling

// Handle different API response scenarios  
Branch Node: "Response Router"

Condition 1: "Success Response"
Expression: {{!ctx.nodes.apiCall.error && ctx.nodes.apiCall.metadata.statusCode >= 200 && ctx.nodes.apiCall.metadata.statusCode < 300}}
→ Connects to: Process Data Node

Condition 2: "Retry Errors"
Expression: {{ctx.nodes.apiCall.metadata.statusCode >= 500}}
→ Connects to: Retry Logic Node

Condition 3: "Client Errors"
Expression: {{ctx.nodes.apiCall.metadata.statusCode >= 400 && ctx.nodes.apiCall.metadata.statusCode < 500}}
→ Connects to: Error Handler Node