금. 8월 15th, 2025

G: Are your n8n workflows feeling a bit… linear? 🤔 Do you wish your automations could make smarter decisions, handle different scenarios, and respond dynamically to varying data? You’re in luck! The n8n If node is your gateway to building truly intelligent and resilient workflows.

Think of it as the brain of your automation, allowing it to evaluate conditions and take different paths based on the outcome. No more one-size-fits-all processes! 🚀

In this comprehensive guide, we’ll dive deep into the n8n If node, from its basic configuration to 10 powerful, real-world use cases that will transform your understanding of complex automation. Let’s get started!


🧠 What Exactly is the n8n If Node?

At its core, the n8n If node is a conditional logic node. It evaluates one or more conditions based on the incoming data and then directs the workflow down one of two paths: “True” or “False.”

Imagine a bouncer at a club 🧑‍✈️:

  • Condition: “Is the person on the guest list?”
  • If True: “Let them in!” (Workflow continues down the “True” branch)
  • If False: “Send them away!” (Workflow continues down the “False” branch)

This simple yet powerful mechanism allows your workflows to adapt dynamically, handle exceptions, and route data precisely where it needs to go.


🛠️ How to Configure the If Node: A Step-by-Step Guide

Adding an If node to your workflow is straightforward. Let’s break down its key configuration options:

  1. Add the Node: Search for “If” in the node selector and add it to your canvas. Connect the output of the preceding node to the input of your If node.

  2. Basic vs. Advanced Mode:

    • Basic Mode (Default): Ideal for one or a few simple conditions. You add conditions one by one.
    • Advanced Mode: Perfect for complex logic involving multiple conditions and AND/OR groups. This mode gives you more granular control. We’ll focus on this for complex examples.
  3. Defining Conditions: Each condition requires three main components:

    • Value 1: This is the dynamic input you want to evaluate. It usually comes from a previous node’s output. You’ll typically use an expression like {{ $json.fieldName }} to access data.
    • Operation: How do you want to compare Value 1 and Value 2? n8n offers a rich set of operators:
      • Equality: equals, not equals
      • String Matching: contains, not contains, starts with, not starts with, ends with, not ends with, regex, not regex
      • Numerical Comparison: greater than, greater than or equals, less than, less than or equals
      • Existence: is empty, is not empty, is null, is not null
      • Boolean: is true, is false
    • Value 2: This is the comparison target. It can be a static value (e.g., a specific name, a number, true/false) or another dynamic expression.
  4. Combining Multiple Conditions (Advanced Mode): When you switch to Advanced Mode, you’ll see “Rule Sets.”

    • AND Groups: All conditions within an AND group must be true for the group to be considered true.
    • OR Groups: At least one condition within an OR group must be true for the group to be considered true.
    • You can nest AND and OR groups to build highly sophisticated logic! 🤯
  5. True & False Branches: The If node will have two outputs:

    • True: Data passes through this branch if the conditions are met.
    • 🚫 False: Data passes through this branch if the conditions are NOT met. You’ll connect subsequent nodes to these branches to define the different actions.

💡 Why is the If Node Essential for Complex Automation?

  • Dynamic Workflow Paths: Your automation can react differently based on input data.
  • Error Handling & Validation: Catch incorrect or missing data early.
  • Resource Optimization: Only run specific (potentially expensive) operations when necessary.
  • Personalized Responses: Tailor emails, messages, or actions to individual users or scenarios.
  • Data Routing & Filtering: Send specific data records to different systems or processes.
  • Business Logic Implementation: Directly embed your business rules into your workflows.

🎯 10 Core Use Cases to Master the If Node

Let’s dive into practical examples that demonstrate the power of the If node! For each example, we’ll outline the scenario, the logic, and a quick n8n configuration hint.


Use Case 1: Filtering Incoming Emails by Subject Line 📧

Scenario: You receive many support emails, but only those with “URGENT” or “CRITICAL” in the subject need immediate Slack notifications. Others can go to a daily digest.

Logic:

  • Check if the email subject contains “URGENT” OR contains “CRITICAL”.

n8n Configuration (Advanced Mode):

  • Value 1: {{ $json.subject }} (assuming a “Receive Email” or similar node precedes it)
  • Operation: contains
  • Value 2: URGENT
  • Add Condition (OR Group):
    • Value 1: {{ $json.subject }}
    • Operation: contains
    • Value 2: CRITICAL
  • True Branch: Send to Slack notification node.
  • False Branch: Add to a database for daily digest.

Use Case 2: Lead Qualification & CRM Routing 📈

Scenario: New leads come from a web form. If a lead has a “budget” over $5000 AND is from the “Tech” industry, they should be assigned to a senior sales rep. Otherwise, to a junior rep.

Logic:

  • Check if budget is greater than 5000 AND industry equals “Tech”.

n8n Configuration (Advanced Mode):

  • Rule Set 1 (AND Group):
    • Condition 1:
      • Value 1: {{ $json.budget }}
      • Operation: greater than
      • Value 2: 5000
    • Condition 2:
      • Value 1: {{ $json.industry }}
      • Operation: equals
      • Value 2: Tech
  • True Branch: Add to CRM with “Senior Rep” assignment.
  • False Branch: Add to CRM with “Junior Rep” assignment.

Use Case 3: Order Processing Based on Value 💰

Scenario: E-commerce orders come in. Orders over $1000 require an additional fraud check and manual approval. Smaller orders can be auto-processed.

Logic:

  • Check if orderTotal is greater than 1000.

n8n Configuration (Basic Mode is sufficient):

  • Value 1: {{ $json.orderTotal }}
  • Operation: greater than
  • Value 2: 1000
  • True Branch: Trigger fraud check, send approval email.
  • False Branch: Proceed with automatic order fulfillment.

Use Case 4: Data Validation for User Registrations ✅🚫

Scenario: New user registrations need to be validated. If the email field is empty OR the password is less than 8 characters, the registration should be rejected and an error logged.

Logic:

  • Check if email is empty OR password length is less than 8. (Note: For string length, you might use a Code node to get length first, or a Regex if less than isn’t directly available on string length in If node for your n8n version).

n8n Configuration (Advanced Mode):

  • Rule Set 1 (OR Group):
    • Condition 1:
      • Value 1: {{ $json.email }}
      • Operation: is empty
    • Condition 2: (Assuming {{ $json.password.length }} from a previous Code node or direct if available)
      • Value 1: {{ $json.password.length }}
      • Operation: less than
      • Value 2: 8
  • True Branch: Send error notification, log invalid registration.
  • False Branch: Proceed with user account creation.

Use Case 5: Content Publishing Workflow ✍️

Scenario: A new blog post is submitted. If its status is “Draft” AND it has a reviewer assigned, send a notification to the reviewer. If status is “Published”, update the website sitemap.

Logic:

  • Check if status equals “Draft” AND reviewer is not empty.
  • (A second If node or a Switch node could handle the “Published” status).

n8n Configuration (First If Node, Advanced Mode):

  • Rule Set 1 (AND Group):
    • Condition 1:
      • Value 1: {{ $json.status }}
      • Operation: equals
      • Value 2: Draft
    • Condition 2:
      • Value 1: {{ $json.reviewer }}
      • Operation: is not empty
  • True Branch: Send reviewer notification.
  • False Branch: Connect to another If node or Switch node to check for “Published” status.

Use Case 6: Payment Status Handling 💸

Scenario: A webhook receives payment updates. If paymentStatus is “succeeded”, update the order as paid. If “failed”, notify the customer and re-attempt. If “pending”, do nothing for now.

Logic:

  • If Node 1: Check if paymentStatus equals “succeeded”.
  • If Node 2 (from False of If Node 1): Check if paymentStatus equals “failed”.

n8n Configuration:

  • If Node 1:
    • Value 1: {{ $json.paymentStatus }}
    • Operation: equals
    • Value 2: succeeded
    • True Branch: Update order status in database.
    • False Branch: Connect to If Node 2.
  • If Node 2 (connected to If Node 1’s False):
    • Value 1: {{ $json.paymentStatus }}
    • Operation: equals
    • Value 2: failed
    • True Branch: Send customer notification, trigger re-attempt logic.
    • False Branch: End workflow (for “pending” or other statuses).
    • Pro Tip: For more than 2-3 branches, consider using a Switch node for cleaner logic.

Use Case 7: API Response Error Handling 🤖

Scenario: After making an API call, you need to check if it was successful or if an error occurred. If the statusCode is 200, proceed. Otherwise, log the error.

Logic:

  • Check if statusCode equals 200.

n8n Configuration:

  • Value 1: {{ $json.statusCode }} (assuming output from an HTTP Request node)
  • Operation: equals
  • Value 2: 200
  • True Branch: Process API response data.
  • False Branch: Log error message, send alert to admin.

Use Case 8: Dynamic File Processing 📂

Scenario: Files are uploaded to an S3 bucket. If the fileType is “image/jpeg” or “image/png”, resize it. If it’s “application/pdf”, OCR it. Other types are ignored.

Logic:

  • If Node 1: Check if fileType equals “image/jpeg” OR equals “image/png”.
  • If Node 2 (from False of If Node 1): Check if fileType equals “application/pdf”.

n8n Configuration:

  • If Node 1 (Advanced Mode):
    • Rule Set 1 (OR Group):
      • Condition 1: {{ $json.fileType }} equals image/jpeg
      • Condition 2: {{ $json.fileType }} equals image/png
    • True Branch: Image resizing node.
    • False Branch: Connect to If Node 2.
  • If Node 2 (connected to If Node 1’s False):
    • Value 1: {{ $json.fileType }}
    • Operation: equals
    • Value 2: application/pdf
    • True Branch: OCR processing node.
    • False Branch: End workflow (or log unsupported file type).

Use Case 9: User Onboarding Flow Personalization 👋

Scenario: A new user signs up. If their signupSource is “Referral” and they registered as a “Premium” user, send them a special welcome email. Otherwise, send a standard welcome email.

Logic:

  • Check if signupSource equals “Referral” AND userPlan equals “Premium”.

n8n Configuration (Advanced Mode):

  • Rule Set 1 (AND Group):
    • Condition 1:
      • Value 1: {{ $json.signupSource }}
      • Operation: equals
      • Value 2: Referral
    • Condition 2:
      • Value 1: {{ $json.userPlan }}
      • Operation: equals
      • Value 2: Premium
  • True Branch: Send “Special Welcome” email template.
  • False Branch: Send “Standard Welcome” email template.

Use Case 10: Time-Based Automation (Business Hours) ⏰

Scenario: You receive inquiries. If an inquiry comes in during “business hours” (e.g., 9 AM to 5 PM, Monday-Friday), send an immediate reply. Otherwise, send an “out of office” reply.

Logic:

  • This is a bit more complex as the If node itself doesn’t directly know the current time/day. You’d typically use a “Date & Time” node first to extract current day of week and hour.
  • Then, the If node checks if currentDayOfWeek is between 1 (Monday) and 5 (Friday) AND currentHour is between 9 and 17.

n8n Configuration:

  1. Date & Time Node (Precedes If): Set it to “Get Current Date and Time,” and extract “Day of Week (Number)” and “Hour (24h format)” into new JSON fields.
  2. If Node (Advanced Mode):
    • Rule Set 1 (AND Group):
      • Condition 1 (Day of Week):
        • Value 1: {{ $json.currentDayOfWeek }}
        • Operation: greater than or equals
        • Value 2: 1 (Monday)
      • Condition 2 (Day of Week):
        • Value 1: {{ $json.currentDayOfWeek }}
        • Operation: less than or equals
        • Value 2: 5 (Friday)
      • Condition 3 (Hour):
        • Value 1: {{ $json.currentHour }}
        • Operation: greater than or equals
        • Value 2: 9
      • Condition 4 (Hour):
        • Value 1: {{ $json.currentHour }}
        • Operation: less than
        • Value 2: 17 (for 5 PM non-inclusive)
    • True Branch: Send immediate reply.
    • False Branch: Send out-of-office reply.

✨ Best Practices & Pro Tips for the If Node

  • Start Simple: Build your conditions one by one. Don’t try to craft a monstrous AND/OR tree from scratch.
  • Test Thoroughly: Use the “Execute Workflow” button with sample data for both True and False scenarios. Debug your expressions carefully.
  • Use Clear Expressions: n8n’s expression editor is powerful. Use {{ $json.fieldName }} for dynamic values. For specific array items, {{ $json.items[0].fieldName }}.
  • Combine with Other Nodes:
    • Switch Node: For more than 2-3 branches, a Switch node can be cleaner than nested If nodes.
    • Merge Node: Use a Merge node after divergent paths (e.g., True and False branches) to bring them back together for common downstream actions.
    • Code Node: For extremely complex, programmatic logic that’s hard to express with standard If node operations, pre-process data with a Code node and then feed a simpler boolean (True/False) into the If node.
  • Handle Edge Cases: What happens if a field is null or empty? Use is null, is not null, is empty, is not empty operations to manage these.
  • Comment Your Logic: Especially with complex If nodes, add comments to explain why certain conditions are set. Future you (or your teammates) will thank you!
  • Case Sensitivity: Be aware of case sensitivity for string comparisons. If needed, use a Code node to convert strings to toLowerCase() or toUpperCase() before the If node.

⚠️ Common Pitfalls to Avoid

  • Data Type Mismatches: Comparing a string “123” with a number 123 using equals might behave unexpectedly in some contexts. Ensure your data types align or convert them.
  • Incorrect Expressions: Typos in {{ $json.fieldName }} are common. Always double-check!
  • Overly Complex Logic: If your Advanced Mode If node looks like a spaghetti monster 🍝, consider breaking it down into smaller, chained If nodes or using a Switch node.
  • Not Handling Null/Empty Values: Assuming a field will always exist or be populated can lead to errors. Proactively check for is empty or is null.
  • Ignoring the False Branch: Sometimes, the “False” path is just as important as the “True” path for error logging or alternative processing. Don’t leave it dangling!

🎉 Conclusion: Empower Your Automations!

The n8n If node is not just another building block; it’s a fundamental tool that elevates your automations from simple linear tasks to dynamic, intelligent workflows. By mastering its configuration and understanding its myriad use cases, you can build systems that adapt, react, and make decisions just like a human would – but at the speed and scale of a machine! 🤖💨

Start experimenting with these 10 use cases, and soon you’ll be identifying countless opportunities to inject conditional logic into every corner of your n8n world. Happy automating! 🚀

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다