An automation without logic is just a script. By mastering the core logic nodes, you transform simple data transfers into intelligent, decision-making systems.
1Conditional Branching: IF & Switch
The IF node is the binary gatekeeper of any workflow. It evaluates a condition ā score > 80, country == 'US', status != 'closed' ā and routes data to either a True or False output port. It's the if/else of your visual canvas.
When your logic gets more complex and you have more than two outcomes, the Switch node is your tool. Instead of nesting three IF nodes inside each other (which makes your canvas look like a bowl of spaghetti), a single Switch node creates multiple output routes from one decision point. Route leads by region, tickets by priority, or orders by fulfillment type ā all with one node, all readable at a glance.
The practical rule: use IF for binary yes/no decisions, and Switch for any routing that has 3 or more possible paths.
// IF node logic (conceptual)
if (lead.score > 80) {
// Output: TRUE port
-> send to sales team
} else {
// Output: FALSE port
-> add to nurture sequence
}
// Switch node logic (conceptual)
switch (lead.region) {
case 'US': -> US Sales Team
case 'EU': -> EU Sales Team
case 'APAC': -> APAC Sales Team
default: -> General Queue
}2Data Management: Set & Merge
The Set node is deceptively powerful. It's n8n's way of saying 'from this point forward, the data looks like this'. You use it to define new fields, rename confusingly-named API fields to something readable, and most importantly, to prune ā remove all the noise so only the fields your next node needs survive.
This habit of setting data early pays enormous dividends during debugging. When every node downstream sees a clean, predictable object instead of a 40-field API response, mapping variables is trivial and errors are immediately obvious.
The Merge node is the opposite ā it brings things together. It combines data from parallel branches (enriching a contact with data from two different APIs simultaneously, for example) or acts as a synchronization gate that won't proceed until all incoming paths have delivered their data.
// Before Set node: raw API response
{
"user_id": 12345,
"created_at": "2024-01-01",
"first_name": "Alex",
"last_name": "Chen",
"metadata": { ... } // 30+ useless fields
}
// After Set node: clean output
{
"name": "Alex Chen",
"userId": 12345
}3Combining Logic in Real Workflows
The real power surfaces when you combine these four nodes into a coherent decision engine. A typical lead-routing workflow might: (1) Set the incoming webhook payload to a clean { name, email, score, region } object, (2) use a Switch to route by region, (3) within each regional branch, use an IF to check if the score exceeds the threshold for immediate sales outreach, and (4) Merge both the high-score and low-score paths back together into a single stream before logging the result to a Google Sheet.
This pattern ā Set ā Switch ā IF ā Merge ā is not unique to this example. It appears in customer support triage, content publishing pipelines, financial approval flows, and almost every non-trivial automation you'll build.
Master these four nodes and you have the vocabulary to describe almost any business process in n8n.
// Full routing pipeline
[Webhook Trigger]
ā [Set: keep name, email, score, region]
ā [Switch: by region]
ā US Branch: [IF: score > 80]
True ā [Slack: @sales-us]
False ā [HubSpot: add to nurture]
ā EU Branch: [IF: score > 75]
True ā [Slack: @sales-eu]
False ā [HubSpot: EU nurture]
ā [Merge: all paths]
ā [Google Sheets: log result]