▶ Stepthrough Start Learning Free

IF and Switch in n8n: Route Work by Rules

Practice it step by step

Start the free practice

You do every step yourself in a practice copy of n8n. It checks your work as you go, and “Do it for me” finishes any step you get stuck on. Free, about 10 minutes, and nothing touches your real accounts. Open full screen

Free · Live nown8n Automation Toolkitn8nGmailGoogle Sheets~10 min40 stepsBeginner

Updated . Built against the tool’s current screens and checked step by step. How we check this lesson

Real work needs rules: big jobs go to the owner, small ones go in a log, emergencies skip the line. In n8n, two nodes handle that. The If node asks one yes or no question and sends each item down a true or false branch. The Switch node gives you as many outputs as you need, one per rule, plus a fallback for anything that matches none of them. In this free n8n IF and Switch node tutorial you build both on a real-looking workflow, check the data on every branch and publish.

At a glance

QuestionAnswer
What you buildSend each request where it belongs. Use an If node to split big jobs from small ones, then a Switch with named outputs and a fallback to route by service.
Toolsn8n
TimeAbout 10 minutes, 40 steps in 5 parts
LevelBeginner, no coding needed
CostFree
Ways to learn itPractice it step by step

The 5 parts, in short

  1. Send a test request: Run the workflow, Fill in the test form, Pick a service, Enter a budget, and 2 more steps.
  2. Add an If: Add the next step, Search for If, Pick If, Drag in the budget, and 6 more steps.
  3. Connect true and false: Connect true, Connect false.
  4. Add a Switch: Add a step before If, Search for Switch, Pick Switch, First rule: the service, and 14 more steps.
  5. Wire it up and publish: Connect Emergency, Connect Fallback, Publish, Publish it.

Start here first: Find and Use n8n Templates (module 1 of n8n Automation Toolkit)

In the course: Part 9 · n8n Automation Toolkit (Module 48 of the full course)

Part of: n8n Jump Start (step 3 of 7). Next up: n8n: Talk to Your Google Sheets with ChatGPT, from Zero (Free Credits or API Key, Google, Sheet, Chat)

Stepthrough lesson showing an n8n Request a service test form with a 2500 budget
Stepthrough lesson showing an n8n Request a service test form with a 2500 budget

What you will build

You will finish a workflow for Harbor Point Handyman, a small handyman business that takes service requests through an n8n form. The form asks for a name, a service (Repair, Installation or Emergency) and a budget. Two actions are already set up in the workflow: a Gmail step called Send a message that emails the owner, and a Google Sheets step called Append row in sheet that adds the request to a log. What is missing is the part that decides which action each request should reach.

First you add an If node that checks whether the budget is greater than 1,000. Requests over that go down the true branch to the owner, and everything else goes down the false branch to the log. Then the owner asks for more, so you put a Switch in front of the If. Repairs keep the budget check, emergencies go straight to the owner whatever the budget, and anything else, such as installations, lands in a Fallback output that feeds the log.

Who this n8n If node tutorial is for

This module is for small business owners, office managers and anyone who has built a simple n8n workflow and now wants it to make decisions. You do not need to code, write expressions by hand or have an n8n account to practice. The form and the two actions are ready when you start.

If vs Switch in n8n: when to use which

Use the If node when the question has two answers. It has exactly two outputs, true and false, and every item takes one or the other, never both. You can add more conditions with Add condition and combine them with AND or OR.

Use the Switch node when you need three or more routes. In Rules mode each routing rule gets its own output, numbered 0, 1, 2 until you switch on Rename Output and give it a name. The Switch checks the rules in order and sends an item to the first one that matches, unless you turn on the Send data to all matching outputs option. Without a fallback, items that match no rule are simply dropped. Setting Fallback Output to Extra Output gives them their own output, called Fallback, so nothing disappears without you noticing.

Numbers, text and Convert types where required

Every condition compares value1 with value2 using a comparison from one of six groups: String, Number, Date & Time, Boolean, Array and Object. Pick the group that matches your data. A budget is a number, so it uses Number, is greater than. A service name is text, so it uses String, is equal to.

An n8n form sends a Number field as a real number, so the rule works as it is. Data from other places, such as a webhook, sometimes sends numbers as text. If a condition complains about the type, switch on Convert types where required and n8n will convert the value before it compares.

How to use this in your business

Send high-value leads to a salesperson and the rest to a newsletter list. Flag invoices over a set amount for approval. Route support messages by topic to the right person, with a fallback inbox for anything unexpected. Start with an If, reach for a Switch when the routes grow, and always add a fallback.

How the interactive lesson works

Every step is shown first on the left, in the Watch panel, with a short voice-over. Then you do it yourself on the right, in Your turn, on a practice copy of n8n and its test form. If you get stuck, press Do it for me and the step is done for you. No email is sent and nothing goes online, so you can make mistakes freely, then build it for real.

Try it yourself, free

Reading the steps is a start. Doing them is how it sticks. The interactive module walks you through every click in a practice copy of n8n, checks each step, and never touches your real accounts.

Start “IF and Switch in n8n: Route Work by Rules”

Step by step: IF and Switch in n8n: Route Work by Rules

All 40 steps of the interactive module, in order. In the module you watch each one, then do it yourself in a practice copy that checks your work.

1. Send a test request

  1. Run the workflow. This workflow has a form trigger and two actions that aren't connected yet. To get some real data to route, click Execute workflow.

    Harbor Point Handyman's service form is ready, and so are two actions: an email to the owner, and a new row in the request log. Nothing decides which one runs yet. First, get a real request to work with.

  2. Fill in the test form. n8n opened the test form. Fill it in like a customer: type a name, for example Nora Castillo.

    The test version of the form just opened. Fill it in like a customer would.

  3. Pick a service. Under Service, choose Installation.

    For the service, choose Installation.

  4. Enter a budget. In Budget, type 2500.

    And a budget of 2,500 dollars.

  5. Submit. Click Submit.
  6. Back to n8n. Go back to the n8n tab.

    Now go back to n8n. The form step has a green check: the request came in.

2. Add an If

  1. Add the next step. Click the + on the right of On form submission.

    Big jobs should go to the owner, and everything else into the log. That is a yes or no question, which is what the If node is for.

  2. Search for If. In Search nodes..., type if.

    Search for if.

  3. Pick If. Choose If: *Route items to different branches (true/false)*.

    It sends each item down one of two branches: true, or false.

  4. Drag in the budget. Under Conditions, the first box is value1. Drag Budget from the input on the left into it. (Here, click Budget.)

    The condition reads like a sentence: value 1, a comparison, value 2. n8n sees that it's a number and switches the comparison to Number.

  5. Open the comparison. Open the comparison drop-down, which now says is equal to.
  6. Is greater than. Point to Number and choose is greater than.
  7. Set the limit. In value2 (n8n fills in 0 for numbers), replace it with 1000.

    In value 2, type 1000. So the rule is: budget is greater than 1,000.

  8. Execute step. Click Execute step to try the rule on the test request.

    Try it on the test request.

  9. Check the false branch. The request went to True Branch (1 item): 2500 is more than 1000. Click False Branch to see the other side.

    The output shows True Branch, 1 item, because 2,500 is more than 1,000.

  10. Close the node. Nothing went down the false branch this time. Close the node with the × at the top right.

    Nothing went this way this time. Each item takes one branch or the other, never both. Close the node.

3. Connect true and false

  1. Connect true. The If node has two outputs, true and false. Drag from the true dot to Send a message. (Here, click the dot.)

    The If node has two outputs, true and false.

  2. Connect false. Drag from the false dot to Append row in sheet.

    Big jobs now email the owner. Everything else goes in the log.

4. Add a Switch

  1. Add a step before If. Now the owner wants emergencies sent straight to them, whatever the budget. Point to the line between the form and If, and click its + (Add node).

    Now the owner wants more: emergencies should reach them right away, whatever the budget. Two roads aren't enough anymore, so add a Switch in front of the If. Point to the line between the form and If, and click the plus.

  2. Search for Switch. Type switch.

    Search for switch.

  3. Pick Switch. Choose Switch: *Route items depending on defined expression or rules*.

    It lands on that line, so the form now feeds the Switch, and the Switch feeds the If.

  4. First rule: the service. Mode is Rules: one rule per output. In the first rule, drag Service into value1. (Here, click Service.)

    Mode is set to Rules: each rule gets its own output. In the first rule, drag Service into value 1. It is text, so is equal to is right.

  5. Repair. In value2, type Repair.

    In value 2, type Repair.

  6. Rename Output. Outputs are numbered 0, 1, 2 until you name them. Switch on Rename Output.

    Outputs are just numbered 0, 1, 2 until you name them. Switch on Rename Output.

  7. Name it. In Output Name, type Repair.

    Name it Repair.

  8. Add Routing Rule. Click Add Routing Rule.
  9. Second rule. Drag Service into the new rule's value1. (Here, click Service.)
  10. Emergency. In value2, type Emergency.

    This time, type Emergency.

  11. Rename Output. Switch on Rename Output.
  12. Name it. In Output Name, type Emergency.

    And name it Emergency.

  13. Add option. What about installations and anything else? Under Options, click Add option.

    What about installations, or anything else? By default, items that match no rule are dropped. Under Options, click Add option.

  14. Fallback Output. Choose Fallback Output.
  15. Open Fallback Output. It starts at None (default): items that match no rule are ignored. Open the drop-down.

    It starts at None, which means those items are ignored.

  16. Extra Output. Choose Extra Output: *Items will be sent to the extra, separate, output*.

    Now anything that matches no rule gets its own output, called Fallback.

  17. Execute step. Click Execute step to route the test request.
  18. Close the node. The Installation request matched neither rule, so it landed in Fallback (1 item). Close the node with the ×.

    The installation matched neither rule, so it went to Fallback, 1 item. That is exactly why the fallback is there. Close the node.

5. Wire it up and publish

  1. Connect Emergency. Repair is already connected to If, so repairs still get the budget check. Drag from Emergency to Send a message. (Here, click the dot.)

    Repair is already connected to the If, so repairs still get the budget check.

  2. Connect Fallback. Drag from Fallback to Append row in sheet.
  3. Publish. Every route has somewhere to go. Click Publish.

    Every road now leads somewhere.

  4. Publish it. Keep the Version name n8n suggests and click Publish.

    Keep the version name n8n suggests, and click Publish. From now on, every request from the form is routed on its own.

Screenshots

Frequently asked questions

What does the If node do in n8n?
It checks one or more conditions for each item and sends the item to its true output when they pass and to its false output when they do not. Each output can lead to different steps.
What is the difference between the If node and the Switch node?
The If node has two outputs, true and false. The Switch node can have as many outputs as you need, one per routing rule, plus an optional fallback output for items that match no rule.
What happens to items that match no rule in a Switch node?
By default they are ignored. Add the Fallback Output option and set it to Extra Output to send them to a separate Fallback output, or to one of your existing outputs.
Is this course really free?
Yes. Stepthrough is completely free, and the practice copy needs no accounts. To build it for real you need your own n8n and Google accounts, and some of those cost money once you use them for real work.

Start this module free

More in n8n Automation Toolkit

All 7 modules in n8n Automation Toolkit

More n8n tutorials

From the blog

All blog posts

Visual guide

This lesson’s key ideas as quick visual guides: swipe through the slides, or read the same guide as text.

All visual guides

Plain-English definitions, each with an example from a free lesson.

The full AI glossary

  • Request routing rules prompt: Write down who should get which request before you build it in n8n: the condition for each route, the exit names and a fallback…

All free prompt templates

Browse related tutorials