{
  "name": "ezgpt-loop-batches-demo",
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "nodes": [
    {
      "id": "57cb9861-31c0-47e8-b8a8-1e0d1e67c7e4",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "f869d6d7-7b30-48b3-a470-684bb0e93c08",
      "name": "Test Orders",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ],
      "parameters": {
        "mode": "raw",
        "jsonOutput": "{\n  \"orders\": [\n    {\n      \"order_id\": \"O1\",\n      \"amount\": 100\n    },\n    {\n      \"order_id\": \"O2\",\n      \"amount\": 200\n    },\n    {\n      \"order_id\": \"O3\",\n      \"amount\": 300\n    },\n    {\n      \"order_id\": \"O4\",\n      \"amount\": 400\n    },\n    {\n      \"order_id\": \"O5\",\n      \"amount\": 500\n    },\n    {\n      \"order_id\": \"O6\",\n      \"amount\": 600\n    },\n    {\n      \"order_id\": \"O7\",\n      \"amount\": 700\n    }\n  ]\n}",
        "includeOtherFields": false,
        "options": {}
      }
    },
    {
      "id": "5687b8c4-f2b7-47c1-9705-f8e97aa15f9e",
      "name": "Split Orders",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        440,
        0
      ],
      "parameters": {
        "fieldToSplitOut": "orders",
        "include": "noOtherFields",
        "options": {}
      }
    },
    {
      "id": "deb6a8d1-637d-4f5f-9dc2-d87b8d1366b0",
      "name": "Batch Orders",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        660,
        0
      ],
      "parameters": {
        "batchSize": 3,
        "options": {
          "reset": false
        }
      }
    },
    {
      "id": "3ed04b99-559b-4a20-8bec-0095c6cd789b",
      "name": "Processed",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        880,
        140
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "fffe77fd-1cf3-4a38-9ded-3662d884131d",
              "name": "processing_status",
              "type": "string",
              "value": "processed_in_demo"
            },
            {
              "id": "103dab0b-6bef-42ea-9dbd-21add0e5ef0a",
              "name": "batch_number",
              "type": "number",
              "value": "={{ $runIndex + 1 }}"
            },
            {
              "id": "2280d840-267c-4b65-851c-c043f617a796",
              "name": "items_in_batch",
              "type": "number",
              "value": "={{ $input.all().length }}"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    },
    {
      "id": "64dd4cc9-fd4d-4bee-899e-879a140d3665",
      "name": "All Done",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1100,
        -120
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c73f80cf-ef64-4db8-bd80-427322930f56",
              "name": "loop_completed",
              "type": "boolean",
              "value": true
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Test Orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Test Orders": {
      "main": [
        [
          {
            "node": "Split Orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Orders": {
      "main": [
        [
          {
            "node": "Batch Orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Processed": {
      "main": [
        [
          {
            "node": "Batch Orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Batch Orders": {
      "main": [
        [
          {
            "node": "All Done",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Processed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
