Conditions & Branching
Workflows often need to make decisions based on data. VelaFlows provides three branching mechanisms: Condition (if/else), Switch (multi-case), and Fork/Merge (parallel execution).
Condition Node (If/Else)
The Condition node evaluates an expression and routes execution down one of two branches: true or false.
Configuration
| Field | Description |
|---|---|
| Expression | A JavaScript-like expression that evaluates to true or false |
| True Branch | The next node to execute if the expression is true |
| False Branch | The next node to execute if the expression is false |
Expression Syntax
Expressions support standard comparison and logical operators:
// Simple comparison
{{lead.score}} > 80
// String comparison
{{conversation.channel}} === "whatsapp"
// Logical operators
{{lead.score}} > 50 && {{lead.status}} === "active"
// Null checks
{{customer.email}} !== null
// Includes check
{{message.text}}.includes("urgent")Example
A workflow that sends a personalized response based on lead score:
Trigger: Lead Created
--> Condition: {{lead.score}} > 80
--> True: Send VIP welcome message
--> False: Send standard welcome messageSwitch Node (Multi-Case)
The Switch node evaluates a value against up to 10 cases and routes to the matching branch. If no case matches, execution follows the default branch.
Configuration
| Field | Description |
|---|---|
| Value | The expression to evaluate (e.g., {{lead.country}}) |
| Cases | Up to 10 case values, each with a connected node |
| Default | The fallback branch when no case matches |
Example
Route a conversation to the right team based on language:
Trigger: Conversation Created
--> Switch: {{conversation.language}}
Case "en" --> Assign to English team
Case "es" --> Assign to Spanish team
Case "fr" --> Assign to French team
Default --> Assign to General teamFork / Merge (Parallel Execution)
The Fork node splits execution into multiple parallel paths. The Merge node waits for all parallel paths to complete before continuing.
Fork Configuration
| Field | Description |
|---|---|
| Branches | The number of parallel paths (2 or more) |
Merge Configuration
| Field | Description |
|---|---|
| Wait for | Which fork branches must complete before continuing (typically all) |
Example
Enrich a lead from multiple sources simultaneously:
Trigger: Lead Created
--> Fork
Branch 1: Enrich Person (Apollo)
Branch 2: Validate Email (ZeroBounce)
Branch 3: Enrich Company (Lusha)
--> Merge (wait for all)
--> Update Lead with enriched dataFork/Merge is useful when you need to perform multiple independent operations and combine the results. Each branch runs concurrently, reducing total execution time.
Nesting Branches
You can nest conditions inside other conditions, or use conditions inside fork branches:
Trigger: Message Received
--> Condition: {{message.channel}} === "whatsapp"
True --> Condition: {{customer.isVip}}
True --> Route to VIP queue
False --> Route to standard queue
False --> Route to email teamThere is no hard limit on nesting depth, but keep workflows readable. If you find yourself nesting more than 3 levels deep, consider splitting into sub-workflows.
Tips
- Keep expressions simple. Complex logic is better handled by a sequence of Condition nodes than a single complicated expression.
- Use Switch for 3+ cases. If you have more than two branches based on the same value, Switch is cleaner than nested Conditions.
- Fork for independence. Only use Fork when the branches are truly independent. If Branch B depends on Branch A’s output, use sequential nodes instead.
- Always have a default. In Switch nodes, always configure a default branch to handle unexpected values.