ワークフロー論理を学ぶ:マージ、IF、スイッチ操作

上級

これはEngineering分野の自動化ワークフローで、22個のノードを含みます。主にIf, Set, Merge, Switch, ManualTriggerなどのノードを使用。 ワークフロー論理を学ぶ:マージ、IF、およびSwitch操作

前提条件
  • 特別な前提条件なし、インポートしてすぐに使用可能
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "meta": {
    "instanceId": "e409ea34548a2afe2dffba31130cd1cf2e98ebe2afaeed2a63caf2a0582d1da0"
  },
  "nodes": [
    {
      "id": "d6cf9b3d-66b8-4022-8c9d-698e89cd22fd",
      "name": "仕分け開始",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -880,
        608
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "b8c72a1e-0268-4d99-8141-ca14e35cbd6a",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1264,
        192
      ],
      "parameters": {
        "width": 624,
        "height": 596,
        "content": "### Tutorial: The Logic Trio (Merge, IF, Switch)\n\nWelcome! This workflow will teach you the three most important nodes for controlling the flow of your data.\n\n**The Analogy: A Package Sorting Center**\n- **Data Items:** Think of these as packages moving on a conveyor belt.\n- **Merge Node:** A point where multiple conveyor belts combine into one.\n- **IF Node:** A simple sorting gate with two paths (e.g., \"Fragile\" or \"Not Fragile\").\n- **Switch Node:** An advanced sorting machine with many paths (e.g., sorting by destination city).\n\n\n**How to use this tutorial:**\n1.  Click **\"Execute Workflow\"**.\n2.  Follow the flow from left to right, clicking on each node to see its output.\n3.  Read the sticky notes to understand what each node does."
      },
      "typeVersion": 1
    },
    {
      "id": "81532695-73c0-4357-a957-3d0ef580578f",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -272,
        192
      ],
      "parameters": {
        "color": 4,
        "width": 384,
        "height": 604,
        "content": "### 1. The Merge Node\n\n**Analogy:** A conveyor belt where packages from different loading docks (the `Set` nodes) come together.\n\n**What it does:** The Merge node combines multiple streams of data into a single stream.\n\nHere, it's set to **Append** mode, which is the most common. It waits for all incoming data and then passes it all through together.\n\n**➡️ Look at the output. We now have both the letter and the parcel in one list, ready for the next step!**"
      },
      "typeVersion": 1
    },
    {
      "id": "dadbac54-6b31-4a0f-8d5e-b6121467e90e",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        144,
        192
      ],
      "parameters": {
        "color": 4,
        "width": 384,
        "height": 596,
        "content": "### 2. The IF Node\n\n**Analogy:** A simple sorting gate with two paths: a \"true\" path and a \"false\" path.\n\n**What it does:** The IF node checks if a condition is met. If it's true, the data goes down the top output. If it's false, it goes down the bottom output.\n\nHere, we're asking a simple question: **\"Does this package have an `is_fragile` property?\"**\n\n**➡️ The parcel will go down the 'true' path, and the letters (which don't have that property) will go down the 'false' path.**"
      },
      "typeVersion": 1
    },
    {
      "id": "0c330031-eab5-4ee3-8b11-91aee526952a",
      "name": "'壊れやすい'処理を追加",
      "type": "n8n-nodes-base.set",
      "position": [
        624,
        512
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "12345",
              "name": "handling_instructions",
              "type": "string",
              "value": "Handle with care!"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "d14c0e68-3823-4f15-98eb-58a0d4983861",
      "name": "'標準'処理を追加",
      "type": "n8n-nodes-base.set",
      "position": [
        624,
        704
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "12345",
              "name": "handling_instructions",
              "type": "string",
              "value": "Standard handling"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "2ebde854-aa6b-48de-83b1-33950a1486e0",
      "name": "付箋3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        816,
        272
      ],
      "parameters": {
        "color": 5,
        "width": 384,
        "height": 552,
        "content": "### Merge Again?\n\n**Why do we need another Merge node here?**\n\nAfter the IF node, our data was split into two different paths. Before we can perform the *next* sorting step on all packages, we need to get them back onto the same conveyor belt.\n\nThis is a very common and important pattern in n8n: \n**Split -> Process -> Merge.**"
      },
      "typeVersion": 1
    },
    {
      "id": "66ca4ac5-aceb-426e-ab22-50c012602a85",
      "name": "付箋4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        176
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 648,
        "content": "### 3. The Switch Node\n\n**Analogy:** An advanced sorting machine that can send packages to many different destinations.\n\n**What it does:** The Switch node is like an IF node with multiple doors. It checks the value of a single field (`destination` in this case) and sends the data down the path that matches the value.\n\n- If the destination is \"London\", it goes to output 0.\n- If it's \"New York\", it goes to output 1.\n- If it's something else, it goes to the **default** output.\n\n\n**➡️ This is much cleaner than using many IF nodes chained together!**"
      },
      "typeVersion": 1
    },
    {
      "id": "10f56a78-85cd-4c8b-88e0-b6b3f0346e89",
      "name": "ロンドン用ビンへ送信",
      "type": "n8n-nodes-base.set",
      "position": [
        1776,
        320
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "12345",
              "name": "sorting_bin",
              "type": "string",
              "value": "A1 (London)"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "2cba95bd-2c9b-42d1-90cb-74c2edf97ec7",
      "name": "ニューヨーク用ビンへ送信",
      "type": "n8n-nodes-base.set",
      "position": [
        1776,
        512
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "12345",
              "name": "sorting_bin",
              "type": "string",
              "value": "B2 (New York)"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "1531b4e3-eece-4c89-98bd-e9633fdd77f6",
      "name": "東京用ビンへ送信",
      "type": "n8n-nodes-base.set",
      "position": [
        1776,
        704
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "12345",
              "name": "sorting_bin",
              "type": "string",
              "value": "C3 (Tokyo)"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "d46604a8-663e-42bd-a175-a34edb8953fb",
      "name": "デフォルトビン",
      "type": "n8n-nodes-base.set",
      "position": [
        1776,
        896
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "12345",
              "name": "sorting_bin",
              "type": "string",
              "value": "Return to Sender"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "570040aa-3f8d-4f59-904a-ee3deb36a9df",
      "name": "最終仕分け済みパッケージ",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2160,
        624
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "756313e7-d2f3-45cc-a4f5-f91e7a8f778a",
      "name": "付箋5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2032,
        272
      ],
      "parameters": {
        "color": 6,
        "width": 368,
        "height": 560,
        "content": "### All Packages Sorted!\n\nCongratulations! You've successfully used the three logic nodes to sort your packages.\n\n**You learned how to:**\n- **Merge** data from different sources.\n- Use **IF** for simple true/false decisions.\n- Use **Switch** for complex, multi-path routing.\n\n\nMastering these three nodes is the key to building powerful and intelligent workflows in n8n."
      },
      "typeVersion": 1
    },
    {
      "id": "4466652f-cc2b-47b1-bf4f-98d89753881f",
      "name": "3. Switch Node",
      "type": "n8n-nodes-base.switch",
      "position": [
        1392,
        576
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "London",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "8d43cde4-027a-4ca7-a24c-6f74f12d6238",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.destination }}",
                    "rightValue": "London"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "New York",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "399a0fbd-6be5-48e9-9f66-04cf385cb418",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.destination }}",
                    "rightValue": "New York"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Tokyo",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a69d387d-a174-42b3-bc5f-c8b46b7c2375",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.destination }}",
                    "rightValue": "Tokyo"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "Default"
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "add68013-30a7-43db-93d4-5af691764684",
      "name": "手紙を作成",
      "type": "n8n-nodes-base.set",
      "position": [
        -496,
        416
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "12345",
              "name": "package_id",
              "type": "string",
              "value": "L-001"
            },
            {
              "id": "67890",
              "name": "type",
              "type": "string",
              "value": "letter"
            },
            {
              "id": "abcde",
              "name": "destination",
              "type": "string",
              "value": "London"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5af75a45-b912-41c6-b073-03188ae914ef",
      "name": "1. Merge Node",
      "type": "n8n-nodes-base.merge",
      "position": [
        -128,
        592
      ],
      "parameters": {
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "11627c3b-465a-4a4a-bfe9-95c08d502f2f",
      "name": "2. IF Node",
      "type": "n8n-nodes-base.if",
      "position": [
        272,
        608
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a68aad83-1d09-4ebe-9732-aaedc407bb4b",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.is_fragile }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "4b5b5ba4-25e1-4ef0-93d8-50670dbc1ce0",
      "name": "全パッケージを再グループ化",
      "type": "n8n-nodes-base.merge",
      "position": [
        960,
        608
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "21d270c4-c19c-42ed-a6e3-67ecedd1c0c9",
      "name": "2通目の手紙を作成",
      "type": "n8n-nodes-base.set",
      "position": [
        -496,
        608
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "12345",
              "name": "package_id",
              "type": "string",
              "value": "L-002"
            },
            {
              "id": "67890",
              "name": "type",
              "type": "string",
              "value": "letter"
            },
            {
              "id": "abcde",
              "name": "destination",
              "type": "string",
              "value": "Tokyo"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8a295323-9515-410c-9ac1-fb431d08cea2",
      "name": "小包を作成",
      "type": "n8n-nodes-base.set",
      "position": [
        -496,
        800
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "12345",
              "name": "package_id",
              "type": "string",
              "value": "P-001"
            },
            {
              "id": "67890",
              "name": "type",
              "type": "string",
              "value": "parcel"
            },
            {
              "id": "abcde",
              "name": "destination",
              "type": "string",
              "value": "New York"
            },
            {
              "id": "fghij",
              "name": "is_fragile",
              "type": "boolean",
              "value": true
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c06a0f40-cc18-4710-8b07-9d396e89a83d",
      "name": "付箋10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2432,
        32
      ],
      "parameters": {
        "color": 3,
        "width": 540,
        "height": 800,
        "content": "## Was this helpful? Let me know!\n\nI really hope this template helped you understand how Logical Operation Nodes work here in n8n. Your feedback is incredibly valuable and helps me create better resources for the n8n community.\n\n### **Share Your Thoughts & Ideas**\n\nWhether you have a suggestion, found a typo, or just want to say thanks, I'd love to hear from you!\nHere's a simple n8n form built for this purpose:\n\n#### ➡️ **[Click here to give feedback](https://api.ia2s.app/form/templates/feedback?template=Merge%20If%20Switch)**\n\n### **Ready to Build Something Great?**\n\nIf you're looking to take your n8n skills or business automation to the next level, I can help.\n\n**🎓 n8n Coaching:** Want to become an n8n pro? I offer one-on-one coaching sessions to help you master workflows, tackle specific problems, and build with confidence.\n#### ➡️ **[Book a Coaching Session](https://api.ia2s.app/form/templates/coaching?template=Merge%20If%20Switch)**\n\n**💼 n8n Consulting:** Have a complex project, an integration challenge, or need a custom workflow built for your business? Let's work together to create a powerful automation solution.\n#### ➡️ **[Inquire About Consulting Services](https://api.ia2s.app/form/templates/consulting?template=Merge%20If%20Switch)**\n\n---\n\nHappy Automating!\nLucas Peyrin"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "11627c3b-465a-4a4a-bfe9-95c08d502f2f": {
      "main": [
        [
          {
            "node": "0c330031-eab5-4ee3-8b11-91aee526952a",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "d14c0e68-3823-4f15-98eb-58a0d4983861",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d46604a8-663e-42bd-a175-a34edb8953fb": {
      "main": [
        [
          {
            "node": "570040aa-3f8d-4f59-904a-ee3deb36a9df",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5af75a45-b912-41c6-b073-03188ae914ef": {
      "main": [
        [
          {
            "node": "11627c3b-465a-4a4a-bfe9-95c08d502f2f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "add68013-30a7-43db-93d4-5af691764684": {
      "main": [
        [
          {
            "node": "5af75a45-b912-41c6-b073-03188ae914ef",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8a295323-9515-410c-9ac1-fb431d08cea2": {
      "main": [
        [
          {
            "node": "5af75a45-b912-41c6-b073-03188ae914ef",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "d6cf9b3d-66b8-4022-8c9d-698e89cd22fd": {
      "main": [
        [
          {
            "node": "8a295323-9515-410c-9ac1-fb431d08cea2",
            "type": "main",
            "index": 0
          },
          {
            "node": "21d270c4-c19c-42ed-a6e3-67ecedd1c0c9",
            "type": "main",
            "index": 0
          },
          {
            "node": "add68013-30a7-43db-93d4-5af691764684",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4466652f-cc2b-47b1-bf4f-98d89753881f": {
      "main": [
        [
          {
            "node": "10f56a78-85cd-4c8b-88e0-b6b3f0346e89",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "2cba95bd-2c9b-42d1-90cb-74c2edf97ec7",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "1531b4e3-eece-4c89-98bd-e9633fdd77f6",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "d46604a8-663e-42bd-a175-a34edb8953fb",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "21d270c4-c19c-42ed-a6e3-67ecedd1c0c9": {
      "main": [
        [
          {
            "node": "5af75a45-b912-41c6-b073-03188ae914ef",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "1531b4e3-eece-4c89-98bd-e9633fdd77f6": {
      "main": [
        [
          {
            "node": "570040aa-3f8d-4f59-904a-ee3deb36a9df",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "10f56a78-85cd-4c8b-88e0-b6b3f0346e89": {
      "main": [
        [
          {
            "node": "570040aa-3f8d-4f59-904a-ee3deb36a9df",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2cba95bd-2c9b-42d1-90cb-74c2edf97ec7": {
      "main": [
        [
          {
            "node": "570040aa-3f8d-4f59-904a-ee3deb36a9df",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4b5b5ba4-25e1-4ef0-93d8-50670dbc1ce0": {
      "main": [
        [
          {
            "node": "4466652f-cc2b-47b1-bf4f-98d89753881f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0c330031-eab5-4ee3-8b11-91aee526952a": {
      "main": [
        [
          {
            "node": "4b5b5ba4-25e1-4ef0-93d8-50670dbc1ce0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d14c0e68-3823-4f15-98eb-58a0d4983861": {
      "main": [
        [
          {
            "node": "4b5b5ba4-25e1-4ef0-93d8-50670dbc1ce0",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

上級 - エンジニアリング

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

関連ワークフロー

並列処理で速度を最適化した重要なワークフロー(ファンアウト-ファンイン)
並列処理(ファンアウト/ファンイン)を活用した速度クリティカルなワークフローを最適化
If
Set
Code
+
If
Set
Code
34 ノードLucas Peyrin
エンジニアリング
待機ノード付きの長時間実行ワークフロー状態管理システム
待機ノード付きの長時間実行ワークフロー状態管理システム
If
Set
Code
+
If
Set
Code
42 ノードLucas Peyrin
エンジニアリング
🧑‍🎓 漸進のな表現の課題を通じてデータアクセス技術を習得
🧑‍🎓 プログレッシブな式の課題を通じてデータアクセス技術を習得
If
Set
Html
+
If
Set
Html
62 ノードLucas Peyrin
エンジニアリング
データ同期を学ぶ:在庫監査チュートリアル
データ同期を学ぶ:在庫監査チュートリアル
Set
Split Out
Manual Trigger
+
Set
Split Out
Manual Trigger
17 ノードLucas Peyrin
エンジニアリング
AI スマートアシスタント: Supabase ストレージと Google Drive ファイルとの対話
AIワンチャットボット:SupabaseストレージとGoogle Driveのファイルと対話
If
Set
Wait
+
If
Set
Wait
62 ノードMark Shcherbakov
エンジニアリング
データとの対話:テキストをSQLクエリおよび可視化グラフに変換
データと対話:テキストをSQLクエリおよび可視化グラフに変換
If
Set
Merge
+
If
Set
Merge
36 ノードhippolyte-hu
エンジニアリング
ワークフロー情報
難易度
上級
ノード数22
カテゴリー1
ノードタイプ7
難易度説明

上級者向け、16ノード以上の複雑なワークフロー

作成者
Lucas Peyrin

Lucas Peyrin

@lucaspeyrin

Innovative builder with a passion for crafting automation solutions that solve real-world challenges. From streamlining workflows to driving efficiency, my work empowers teams and individuals to achieve more with less effort. Experienced in developing scalable tools and strategies that deliver results with n8n, supabase and cline.

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34