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
| Property | Value |
|---|---|
| Code | branch |
| Workflow Types | Workflow |
Connections
| Direction | Description |
|---|---|
| Incoming | Single input connection from previous node |
| Outgoing | Multiple outputs - one for each condition |
Each condition creates a separate output handle with unique connection points for targeted routing.
Condition Management
Adding Conditions
- Create Condition: Click "Add Condition" to create a new branch
- Name Condition: Enter descriptive title for the condition
- Write Expression: Define goval expression that evaluates to boolean
- Connect Output: Link condition output to target node
Condition Structure
Each condition contains:
| Field | Purpose | Example |
|---|---|---|
| Title | Human-readable branch name | "Adult User" |
| Expression | Goval boolean expression | ctx.nodes.start.outputs.age > 18 |
| Output Handle | Unique connection point | condition-{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
- Sequential Processing: Conditions are evaluated in the order they appear
- Context Access: Each expression has access to complete workflow context
- Boolean Requirement: All expressions must evaluate to
trueorfalse - 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 Type | Cause | Solution |
|---|---|---|
| Non-boolean result | Expression returns non-boolean value | Ensure expression evaluates to true/false |
| All conditions false | No conditions evaluate to true | Add default condition or fix logic |
| Expression error | Invalid goval syntax | Validate expression syntax |
| Context access error | Referenced node/property doesn't exist | Verify 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
| Problem | Symptoms | Solution |
|---|---|---|
| Branch doesn't execute | No output connections trigger | Check condition expressions return boolean |
| All paths fail | "All conditions false" error | Add default condition with {{true}} |
| Unexpected routing | Wrong path executes | Review condition logic and test with sample data |
| Expression errors | Node fails during execution | Validate goval syntax and context paths |
Debugging Techniques
- Test Individual Conditions: Use node testing to verify condition results
- Check Context Access: Verify referenced nodes and properties exist
- Simplify Logic: Break complex conditions into smaller parts
- Add Logging: Use subsequent nodes to log condition results
- 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 NodeOrder 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 NodeAPI 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