{
  "name": "ezgpt-merge-orders-demo",
  "active": false,
  "nodes": [
    {
      "id": "b405fe0d-35dc-445c-81fd-85af3d4bd9c7",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "09c4dc07-9077-47d8-894b-c091efda9a89",
      "name": "Test Orders",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        -140
      ],
      "parameters": {
        "mode": "raw",
        "jsonOutput": "{\n  \"orders\": [\n    {\n      \"order_id\": \"O1\",\n      \"customer_id\": \"C1\",\n      \"amount\": 1500\n    },\n    {\n      \"order_id\": \"O2\",\n      \"customer_id\": \"C2\",\n      \"amount\": 2400\n    },\n    {\n      \"order_id\": \"O3\",\n      \"customer_id\": \"C9\",\n      \"amount\": 800\n    }\n  ]\n}",
        "includeOtherFields": false,
        "options": {}
      }
    },
    {
      "id": "1b62071b-f704-4207-b5af-54655f3ac9be",
      "name": "Split Orders",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        500,
        -140
      ],
      "parameters": {
        "fieldToSplitOut": "orders",
        "include": "noOtherFields",
        "options": {}
      }
    },
    {
      "id": "6fd67198-23c7-4da2-8e03-cb3af204fe9c",
      "name": "Test Customers",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        140
      ],
      "parameters": {
        "mode": "raw",
        "jsonOutput": "{\n  \"customers\": [\n    {\n      \"customer_id\": \"C2\",\n      \"customer_name\": \"Учебная компания Б\",\n      \"segment\": \"business\"\n    },\n    {\n      \"customer_id\": \"C1\",\n      \"customer_name\": \"Учебная компания А\",\n      \"segment\": \"small_business\"\n    },\n    {\n      \"customer_id\": \"C3\",\n      \"customer_name\": \"Учебная компания В\",\n      \"segment\": \"business\"\n    }\n  ]\n}",
        "includeOtherFields": false,
        "options": {}
      }
    },
    {
      "id": "d1ef4707-76ad-4c36-aff0-8798c3a93ed8",
      "name": "Split Customers",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        500,
        140
      ],
      "parameters": {
        "fieldToSplitOut": "customers",
        "include": "noOtherFields",
        "options": {}
      }
    },
    {
      "id": "2ef98b71-bbd2-4763-958b-a6a4a96ccbf7",
      "name": "Match Customers",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        780,
        0
      ],
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByFields",
        "advanced": false,
        "fieldsToMatchString": "customer_id",
        "joinMode": "enrichInput1",
        "options": {
          "fuzzyCompare": false,
          "multipleMatches": "all",
          "clashHandling": {
            "values": {
              "resolveClash": "preferInput1",
              "mergeMode": "shallowMerge",
              "overrideEmpty": false
            }
          }
        }
      }
    },
    {
      "id": "9676b6fa-7c1e-4dcc-9c56-f6eb4c91cfd2",
      "name": "Result",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1020,
        0
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "2d5250c3-2480-4688-9b14-3ad9608032c3",
              "name": "customer_found",
              "type": "boolean",
              "value": "={{ typeof $json.customer_name === 'string' && $json.customer_name.trim().length > 0 }}"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Test Orders",
            "type": "main",
            "index": 0
          },
          {
            "node": "Test Customers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Test Orders": {
      "main": [
        [
          {
            "node": "Split Orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Test Customers": {
      "main": [
        [
          {
            "node": "Split Customers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Orders": {
      "main": [
        [
          {
            "node": "Match Customers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Customers": {
      "main": [
        [
          {
            "node": "Match Customers",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Match Customers": {
      "main": [
        [
          {
            "node": "Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
