New-client launch offer: talk to sales about a focused integration pilot using MuleSoft or n8n. See what's included →
Home / Insights / n8n Switch: configuring a fallback route
n8n

n8n Switch: configuring a fallback route

Handle items that match no rule and make unexpected input visible with an explicit fallback output.

Switch routes each item to one of several named outputs based on rules. It is what you want the moment a decision has more than two outcomes, and it keeps the canvas flat where chained IF nodes would build a staircase.

Set the fallback output

By default, an item that matches no rule is dropped. No error is raised, the execution is marked successful, and the item is simply gone.

This is exactly the failure mode that Choice has in MuleSoft when you omit the otherwise — and it produces exactly the same kind of incident. A new status value appears upstream months later, matches nothing, and silently stops being processed. Nobody notices until a report comes up short.

Two different tools, one bug: the unmatched case that nobody routed anywhere.

Set Fallback Output to extra output and send it somewhere that makes noise — a Slack message, a row in an errors sheet, an email. The rule is simple: unmatched should be loud, not invisible.

// rules mode, routing on order status
Output "new"    ←  {{ $json.status }} equals NEW
Output "shipped" ←  {{ $json.status }} equals SHIPPED
Output "cancelled" ←  {{ $json.status }} equals CANCELLED
Fallback       ←  everything else -> alert, do not discard

Name the outputs

Outputs can be renamed, and they should be. "cancelled" on the connector tells the next person what that branch is for; "Output 3" tells them to open the node and work it out. On a workflow you will not touch for six months, this is the cheapest documentation available.

Rules mode or expression mode

  • Rules mode for value matching — a status field, a country code, a document type. Readable on the canvas without opening anything.
  • Expression mode when the branch is computed rather than matched, such as bucketing an amount into tiers. Powerful, but the logic disappears inside the node, so leave a note on the canvas saying what it does.

One item, one output

Like Choice, Switch sends each item down exactly one branch — the first rule it matches. If two rules can be true for the same item, the order of the rules is the business decision. Write that down somewhere the next person will see it.

Building something where this matters?

Discuss a focused integration pilot covering the agreed workflow, error handling, testing and handover. Talk to our team about available new-client launch benefits.

See the scope

More on this

Let’s Talk

Your request has been accepted

Thank you for contacting BraidArc. We typically respond within one business day.

Reference: