Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

n8n: IF vs Switch for Conditional Logic, With the Real Expressions and Node JSON

Описание и применение

В n8n условная логика позволяет маршрутизировать заявки по бюджету и типу услуги, используя узлы If и Switch, а также настройку fallback‑выхода, чтобы избежать потери данных.

Задача

Small businesses need to route form submissions based on budget and service type, but default n8n workflows process every item the same way, causing manual filtering or missed emergencies.

Результат

The workflow now routes high‑budget and emergency requests directly to the owner, logs other requests, and prevents silent loss of data by using a Switch fallback.

Рабочий процесс

  • Add an If node to test if $json.Budget > 1000 and route true to Gmail, false to Google Sheets.
  • Use a Switch node before the If to route Service values: Repair → Gmail, Emergency → Gmail, others → fallback.
  • Configure the Switch fallback output to ensure unmatched items (e.g., Installation) are not lost.
  • Use expressions like {{ Number($json.Budget) }} when budget is sent as text.
  • Stack multiple conditions in the If node with AND/OR as needed.

Доказательства

The If node asks one question and has two exits, true and false. Every item takes one or the other, never both.

Источник

An item that matches none of your Switch rules is ignored by default. No error, no warning. It just stops.

Источник

If your form sends the budget as text, convert it in the expression instead of switching the comparison to String: {{ Number($json.Budget) }}.

Источник

  • Дата записи: 2026-10-24T20:41:06.739Z