Flowchart showing a decision point with two branching paths, true and false

n8n If 節點 (07):打造靈活的條件判斷流程

在自動化流程設計中,僅僅依靠線性節點往往無法應對複雜的邏輯需求。
這時候 If 節點 就顯得特別重要。
它讓我們能夠像程式語言中的 if...else 一樣,根據條件動態決定資料的去向與處理方式。

透過 If 節點,你可以:

  • 根據條件分流,將資料導向不同的處理路徑
  • 建立篩選機制,僅針對符合條件的資料進行後續操作
  • 結合多個比較條件,實現靈活的業務邏輯判斷

換句話說,If 節點是自動化工作流程中 邏輯大腦 的角色,能大幅提升流程的智能與精準度。

Flowchart showing a decision point with two branching paths, true and false

主要功能

根據條件評估將數據流分為兩條路徑:

  • 當條件為真時,數據流向「true」輸出
  • 當條件為假時,數據流向「false」輸出

應用場景

適用於需要基於特定條件執行不同操作的情況:

  • 根據數據值選擇不同處理路徑
  • 實現簡單的「如果-否則」邏輯
  • 過濾符合特定條件的數據

添加條件 (Add Conditions)

為 If 節點創建比較條件 (Conditions)

  1. 使用數據類型下拉菜單選擇數據類型和比較操作類型
  2. 例如,要過濾特定日期之後的日期,選擇 Date & Time > is after
  3. 根據所選數據類型和比較,輸入相應的字段和值
  4. 選擇 Add condition 創建更多條件

您可以通過選擇條件之間的 AND 或 OR 來組合多個條件:

  • AND:數據必須滿足所有條件
  • OR:數據只需滿足任一條件
Form interface showing condition builder with dropdown menus and comparison operators

If 節點支持的數據類型比較 (1/3)

字符串 (String)

  • exists / does not exist
  • is empty / is not empty
  • is equal to / is not equal to
  • contains / does not contain
  • starts with / does not start with
  • ends with / does not end with
  • matches regex / does not match regex

數字 (Number)

  • exists / does not exist
  • is empty / is not empty
  • is equal to / is not equal to
  • is greater than / is less than
  • is greater than or equal to
  • is less than or equal to

If 節點支持的數據類型比較 (2/3)

日期和時間 (Date & Time)

  • exists / does not exist
  • is empty / is not empty
  • is equal to / is not equal to
  • is after / is before
  • is after or equal to
  • is before or equal to

布爾值 (Boolean)

  • exists / does not exist
  • is empty / is not empty
  • is true / is false
  • is equal to / is not equal to

If 節點支持的數據類型比較 (3/3)

數組 (Array)

  • exists / does not exist
  • is empty / is not empty
  • contains / does not contain
  • length equal to / length not equal to
  • length greater than / length less than
  • length greater than or equal to
  • length less than or equal to

對象 (Object)

  • exists / does not exist
  • is empty / is not empty

結語

If 節點雖然簡單,卻是 n8n 流程中不可或缺的核心工具。
它能讓你的工作流程不再只是「一條直線」,而是能夠依情境自動分流、決策與過濾的 智慧化流程

無論是判斷文字是否包含關鍵字、檢查日期是否過期,還是依照布林值執行不同動作,If 節點都能提供靈活解決方案。

Workflow diagram showing If node connected to two paths that reconnect at a Merge node

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

High Quality

Lorem ipsum dolor sit amet, consectetur adipiscing elitsed do eiusmod tempor.

Fast Delivery

Lorem ipsum dolor sit amet, consectetur adipiscing elitsed do eiusmod tempor.

Best Warranty

Lorem ipsum dolor sit amet, consectetur adipiscing elitsed do eiusmod tempor.