Branch Module by FlowMattic
The Branch module is a powerful workflow component in FlowMattic that allows you to create conditional paths within your workflows. It provides a simplified alternative to the Router module for scenarios where you need to execute different actions based on a single condition with Yes/No outcomes.
Why Branch When We Have Router?
While both modules handle conditional workflow execution, they serve different purposes and use cases:
Router Module
- Multiple Routes: Requires you to add conditions to each Route separately
- Complex Workflows: Ideal for workflows with multiple conditional paths (3+ routes)
- Individual Route Conditions: Each route must have its own condition evaluation
- Use Case: Perfect for complex decision trees with multiple outcomes
Example Router Use Case:
- Route A: If user role = "admin" → Execute admin tasks
- Route B: If user role = "editor" → Execute editor tasks
- Route C: If user role = "subscriber" → Execute subscriber tasks
- Route D: Default → Execute guest tasks
Branch Module
- Binary Decision: Evaluates single or multiple conditions with Yes/No outcomes
- Simplified Setup: Define conditions only once for the entire branch
- Cleaner Workflows: More readable and easier to understand
- Nested Support: Can be nested for complex conditions
- Use Case: Perfect for binary decisions and conditional logic
Example Branch Use Case:
- Condition: Has user submitted X field in the form?
- Yes Path → Continue to add the form to CRM
- No Path → Email user to fill the required fields
How Branch Module Works
1. Condition Evaluation
The Branch step evaluates a specified condition using the same Filter system as other FlowMattic modules. Based on the outcome:
- Conditions Meet → Executes the Yes path
- Conditions Don’t Meet → Executes the No path
2. Path Execution Logic
- Yes Path: When conditions are met, the workflow executes all steps in the Yes path
- No Path: When conditions are not met, the workflow skips all Yes path steps and executes the No path
- Separate Paths: Yes and No paths are completely independent - each path executes its own set of actions
3. Visual Structure
Important: Each branch path (Yes/No) is a separate execution flow. After executing either the Yes path or the No path, the workflow ends at that branch unless you have additional steps or branches after the current branch structure.
Setting Up a Branch
1. Add Branch Step
- Add new action step and choose the Branch module from the app library into your workflow
- The system automatically creates:
- Branch node (main condition)
- Yes branch route
- No branch route
2. Configure Branch Condition
- Click on the Branch step to open settings
- Set up your conditions for evaluation:
- Field: Select the data field to evaluate
- Condition: Choose comparison operator (equals, contains, greater than, etc.)
- Value: Set the value to compare against
- Logic: Choose AND/OR for multiple conditions
3. Add Steps to Paths
- Yes Path: Add steps that should execute when conditions are met
- No Path: Add steps that should execute when conditions are not met
- Each step will automatically be connected to the appropriate path
Examples and Use Cases
Example 1: Lead Qualification for Sales Team
**Scenario**: Automatically qualify leads based on company size and route them appropriately
**Branch Condition**:
- Field: `{form.company_size}`
- Condition: `greater than`
- Value: `50`
**Yes Path (Enterprise Lead)**:
1. Add to CRM with "Hot Lead" tag
2. Assign to Senior Sales Rep
3. Send personalized enterprise welcome email
4. Schedule automatic follow-up call
5. Add to enterprise nurture campaign
**No Path (Small Business Lead)**:
1. Add to CRM with "SMB Lead" tag
2. Send automated product demo video
3. Add to self-service onboarding sequence
4. Send pricing information
Example 2: Order Value Processing
**Scenario**: Handle orders differently based on order value
**Branch Condition**:
- Field: `{webhook.order_total}`
- Condition: `greater than`
- Value: `100`
**Yes Path (High Value Orders)**:
1. Apply VIP Processing
2. Assign Priority Support
3. Send Premium Thank You Email
4. Add to VIP Customer List
**No Path (Standard Orders)**:
1. Standard Processing
2. Send Standard Confirmation
3. Add to Regular Customer List
Example 3: Customer Support Ticket Routing
**Scenario**: Route support tickets based on customer type and urgency
**Primary Branch**: Is Premium Customer?
├── **Yes Path (Premium Customer)**:
│ ├── Assign to dedicated account manager
│ ├── Send priority support acknowledgment
│ └── **Nested Branch**: Is Critical Issue?
│ ├── **Yes Path**:
│ │ ├── Create urgent ticket
│ │ ├── Send SMS alert to support manager
│ │ └── Start 1-hour response timer
│ └── **No Path (Non-Critical)**:
│ ├── Create standard priority ticket
│ └── Send email with 4-hour response commitment
└── **No Path (Regular Customer)**:
├── Assign to general support queue
├── Send auto-reply with FAQ links
└── Create ticket with 24-hour response time
Note: The nested branch only applies to premium customers, allowing for more refined handling of their issues.
Example 4: Error Handling
**Scenario**: Handle API response errors gracefully
**Branch Condition**:
- Field: `{api.status_code}`
- Condition: `equals`
- Value: `200`
**Yes Path (Success)**:
1. Process API Data
2. Update Database
3. Send Success Notification
**No Path (Error)**:
1. Log Error Details
2. Send Alert to Admin
3. Show User-Friendly Error Message
4. Retry Logic (if applicable)
Best Practices
1. When to Use Branch vs Router
-
Use Branch when:
- You have a simple Yes/No decision
- You want cleaner, more readable workflows
- You need to evaluate a single condition
- You’re building binary logic flows
-
Use Router when:
- You have 3+ different outcomes
- Each path needs different conditions
- You need complex multi-route logic
- You’re building complex decision trees
2. Condition Design
- Keep conditions simple: Focus on single, clear conditions
- Use descriptive names: Label your branches clearly
- Test thoroughly: Verify both Yes and No paths work correctly
- Handle edge cases: Consider what happens with null/empty values
3. Nesting Guidelines
- Limit nesting depth: Keep to 2-3 levels maximum for readability
- Document complex logic: Use clear naming for nested branches
- Consider alternatives: Sometimes a Router might be cleaner than deeply nested branches
4. Error Prevention
- Always define both paths: Ensure both Yes and No paths have appropriate actions
- Validate data: Check that the data you’re evaluating exists
- Default values: Consider what happens when conditions can’t be evaluated
Advanced Features
1. Dynamic Conditions
Use dynamic data in your branch conditions:
**Condition**: Compare user's current plan with target plan
- Field: `{user.current_plan}`
- Condition: `equals`
- Value: `{webhook.target_plan}`
2. Multiple Condition Logic
Combine multiple conditions with AND/OR logic:
**Complex Condition**: User is premium AND order value > 50
- Condition 1: `{user.plan}` equals `premium`
- Logic: `AND`
- Condition 2: `{order.total}` greater than `50`
3. Branch Data Access
Access branch execution results in subsequent steps:
**Available Data**:
- `{branch2.path_to_execute}` → Returns "yes" or "no"
- `{branch2.condition_met}` → Returns true or false
Troubleshooting
Common Issues
- Wrong path executing: Check that branch conditions are properly configured
- Conditions not evaluating: Verify that the data fields exist and contain expected values
- Steps not executing: Ensure steps are properly connected to the correct branch path
- Nested branches failing: Check the logic flow and ensure parent branch conditions are met
Debug Tips
- Test conditions: Use the test feature to verify your conditions work as expected
- Check data: Review the workflow execution logs to see actual data values
- Simplify first: Start with simple conditions and add complexity gradually
- Use logging: Add logging steps to track which path is being executed
Migration from Router
If you’re migrating simple binary decisions from Router to Branch:
- Identify binary Router patterns: Look for Routers with only 2 routes
- Extract the condition: Take the condition from the first route
- Create Branch: Replace Router with Branch using that condition
- Move steps: Move Route 1 steps to Yes path, Route 2 steps to No path
- Test thoroughly: Verify the new branch works the same as the original Router
Conclusion
The Branch module simplifies conditional workflow creation by providing a clean, intuitive way to handle Yes/No decisions. Use it to:
- Simplify workflows: Replace complex Router setups for binary decisions
- Improve readability: Make your workflows easier to understand and maintain
- Reduce complexity: Minimize the number of conditional configurations needed
- Enhance maintenance: Make it easier to update and modify conditional logic
By choosing the right conditional module (Branch vs Router) for your specific use case, you can create more efficient, maintainable, and understandable workflows in FlowMattic.