How to Use the IF/Switch Node (Conditional Logic)
Routing workflows based on conditions (e.g., new vs. existing client, past vs. future event).
How to Use the IF/Switch Node (Conditional Logic)
Every professional services workflow needs decision points. Route new clients to onboarding. Send overdue invoices to collections. Assign high-value matters to senior partners. The IF and Switch nodes in n8n handle these routing decisions.
This guide shows you exactly how to configure both nodes, when to use each, and how to avoid the common mistakes that break conditional logic.
When to Use IF vs. Switch
Use IF when:
- You have 2-3 possible outcomes
- Your condition is binary (yes/no, true/false)
- You're checking a single field with simple logic
Use Switch when:
- You have 4+ possible outcomes
- You're routing based on status fields (new/warm/hot/closed)
- You need a default "catch-all" path
Real example: Routing client intake forms. IF works for "Is this a conflict check? Yes/No." Switch works for "What practice area? Corporate/Litigation/Tax/Employment/Other."
Configuring the IF Node
The IF node evaluates conditions and sends data down one of two paths: true or false.
Step 1: Add the IF Node
- Click the
+button in your workflow - Search for "IF" and select it
- Connect it to your trigger or previous node
Step 2: Set Your Condition
Click "Add Condition" and configure three fields:
Field Name: Enter the exact JSON path to your data. Examples:
{{ $json.status }}for a status field{{ $json.client.type }}for nested data{{ $json.invoice.amount }}for numeric values
Operation: Choose your comparison type:
Equal- exact match (case-sensitive)Not Equal- anything except this valueContains- partial text matchGreater Than/Less Than- numeric comparisonsIs Empty/Is Not Empty- check for missing dataRegex- pattern matching (advanced)
Value: Enter what you're comparing against. Can be:
- Static text:
new client - Numbers:
5000 - Dates:
2024-01-01 - Expressions:
{{ $now.minus(30, 'days') }}
Step 3: Add Multiple Conditions (Optional)
Click "Add Condition" again to create AND/OR logic.
AND logic (all must be true):
- Condition 1:
statusequalsnew - Condition 2:
amountgreater than10000 - Result: Only new clients with invoices over $10k proceed
OR logic (any can be true): Change the dropdown from "AND" to "OR" at the top of the conditions panel.
Step 4: Connect Output Paths
The IF node creates two output connections:
True path: Drag from the green "true" dot to the next node that handles matching records.
False path: Drag from the red "false" dot to the node that handles non-matching records.
Real-World IF Node Example: Client Type Routing
Scenario: Route new client intake forms to different onboarding workflows.
Configuration:
- Add IF node after your intake form trigger
- Set condition:
- Field:
{{ $json.clientType }} - Operation:
Equal - Value:
individual
- True path: Connect to "Individual Client Onboarding" workflow
- False path: Connect to "Business Client Onboarding" workflow
Result: Individual clients get personal service agreements. Business clients get corporate engagement letters.
Configuring the Switch Node
The Switch node routes data to multiple paths based on a single field's value. Think of it as a multi-way IF statement.
Step 1: Add the Switch Node
- Click
+in your workflow - Search for "Switch" and select it
- Connect it to your trigger or previous node
Step 2: Define Your Routing Field
In "Mode" dropdown, select "Rules" (most common) or "Expression" (advanced).
Rules Mode: Set "Data Property Name" to the field you're evaluating:
{{ $json.status }}{{ $json.practiceArea }}{{ $json.priority }}
Step 3: Create Output Rules
Click "Add Routing Rule" for each possible outcome.
For each rule, configure:
Output: Name this path (appears as the connection label). Use clear names like "New Leads", "Hot Prospects", "Existing Clients".
Conditions: Set the matching criteria:
- Operation: Usually "Equal" for status-based routing
- Value: The exact value that triggers this path
Example rule set for lead routing:
Rule 1:
- Output:
New - Operation:
Equal - Value:
new
Rule 2:
- Output:
Warm - Operation:
Equal - Value:
warm
Rule 3:
- Output:
Hot - Operation:
Equal - Value:
hot
Rule 4:
- Output:
Closed - Operation:
Equal - Value:
closed
Step 4: Add a Fallback Path
Always enable "Add Fallback Output". This catches any values that don't match your rules.
Name it "Other" or "Unmatched" and connect it to an error notification or manual review queue.
Step 5: Connect Each Output
Drag from each labeled output dot to the appropriate next node in your workflow.
Real-World Switch Node Example: Matter Assignment
Scenario: Assign new legal matters to attorneys based on practice area.
Configuration:
- Add Switch node after matter intake form
- Set Data Property Name:
{{ $json.practiceArea }} - Create rules:
- Output:
Corporate| Value:corporate - Output:
Litigation| Value:litigation - Output:
Tax| Value:tax - Output:
Employment| Value:employment
- Enable fallback output:
General - Connect each output:
- Corporate → Assign to Corporate Team node
- Litigation → Assign to Litigation Team node
- Tax → Assign to Tax Team node
- Employment → Assign to Employment Team node
- General → Assign to Managing Partner node
Result: Each matter routes to the correct department automatically. Unrecognized practice areas go to the managing partner for manual assignment.
Advanced Pattern: Date-Based Routing
Route workflows based on whether events are past or future.
Use case: Send different emails for upcoming vs. past-due invoices.
Configuration:
- Add IF node
- Set condition:
- Field:
{{ $json.dueDate }} - Operation:
Smaller - Value:
{{ $now }}
- True path (past due): Send overdue notice
- False path (upcoming): Send payment reminder
Key detail: Both dueDate and $now must be in ISO 8601 format (YYYY-MM-DD) for comparison to work.
Advanced Pattern: Nested Conditionals
Layer IF or Switch nodes to create decision trees.
Use case: Route client communications based on both client type AND engagement status.
Structure:
- First Switch node: Route by client type (Individual/Business/Government)
- Within "Business" path, add second IF node: Check if engagement is active
- True path: Send active client update
- False path: Send reactivation offer
Why this works: You avoid creating 6+ separate rules in a single Switch node. Each layer handles one decision cleanly.
Advanced Pattern: Numeric Ranges
Route based on value thresholds.
Use case: Escalate high-value opportunities to partners.
Configuration using IF node:
- Add IF node after opportunity creation
- Add two conditions (AND logic):
- Condition 1:
{{ $json.amount }}Greater Than50000 - Condition 2:
{{ $json.status }}Equalopen
- True path: Assign to partner
- False path: Assign to associate
Alternative using Switch node with multiple rules:
- Add Switch node
- Set Data Property Name:
{{ $json.amount }} - Create rules:
- Output:
Tier1| Operation:Larger| Value:100000 - Output:
Tier2| Operation:Larger| Value:50000 - Output:
Tier3| Operation:Larger| Value:10000
- Enable fallback:
Standard
Important: Switch evaluates rules in order. Put highest values first.
Common Mistakes and Fixes
Mistake 1: Case sensitivity Your condition checks for "New" but the data contains "new". No match.
Fix: Use the toLowerCase() function:
- Field:
{{ $json.status.toLowerCase() }} - Value:
new
Mistake 2: Missing fallback Your Switch node has rules for "new", "warm", "hot" but a record comes through with status "qualified". Workflow breaks.
Fix: Always enable "Add Fallback Output" in Switch nodes.
Mistake 3: Wrong data type
You're comparing {{ $json.amount }} (string "5000") to 5000 (number). No match.
Fix: Convert types explicitly:
- Field:
{{ parseInt($json.amount) }} - Value:
5000
Mistake 4: Empty values
Your condition checks if {{ $json.notes }} equals "urgent" but the field is empty. Workflow errors.
Fix: Add a preliminary IF node:
- Condition:
{{ $json.notes }}Is Not Empty - True path: Check for "urgent"
- False path: Default handling
Mistake 5: Overcomplicating with expressions You write a 10-line expression to handle 5 different statuses.
Fix: Use a Switch node instead. One rule per status. Cleaner and easier to maintain.
Testing Your Conditional Logic
Before activating your workflow:
- Test each path: Use the "Execute Node" button with sample data that matches each condition
- Test edge cases: Empty fields, null values, unexpected formats
- Test the fallback: Send data that doesn't match any rule
- Check the execution log: Verify data flows to the correct output path
Pro tip: Add a "Sticky Note" node before each conditional with example values that should trigger that path. Makes testing faster.
Performance Considerations
IF nodes are faster than Switch nodes for simple binary decisions. Use IF when you only need two outcomes.
Switch nodes are cleaner than chained IF nodes when you have 4+ outcomes. One Switch node beats three nested IF nodes.
Avoid deep nesting. If you're 4+ levels deep in conditional logic, restructure your workflow. Consider using a Function node with JavaScript for complex decision trees.
Bottom Line
Use IF nodes for binary decisions. Use Switch nodes for multi-way routing. Always add fallback paths. Test with real data before going live.
Master these two nodes and you can automate any routing decision in your firm.

Reviewed by Revenue Institute
This guide is actively maintained and reviewed by the implementation experts at Revenue Institute. As the creators of The AI Workforce Playbook, we test and deploy these exact frameworks for professional services firms scaling without new headcount.
Revenue Institute
Need help turning this guide into reality? Revenue Institute builds and implements the AI workforce for professional services firms.