{
  "name": "FLUF — a packing queue in Google Sheets",
  "nodes": [
    {
      "name": "FLUF event",
      "type": "n8n-nodes-fluf-connect.flufConnectTrigger",
      "parameters": {
        "event": "new_sale"
      },
      "position": [
        240,
        300
      ],
      "typeVersion": 1,
      "id": "ee3396ad-2ecc-42ff-9e70-639ee85ed607",
      "webhookId": "734916da-1cf0-4351-9b83-c14557949714"
    },
    {
      "name": "Prepare event",
      "type": "n8n-nodes-base.code",
      "parameters": {
        "jsCode": "return $input.all().map((item, i) => {\n const s = item.json;\n if (s.test || s.synthetic || s.event !== \"new_sale\" || !s.event_id || !s.order_id || !s.channel) throw new Error('Use a real new_sale event with an event_id and required fields.');\n if (!Array.isArray(s.items) || !s.items.length) throw new Error('A packing queue needs the full order items; inspect the order in FLUF.');\n const row = {event_id: String(s.event_id), order_id: String(s.order_id), channel: s.channel, connection_id: String(s.connection_id ?? ''), sold_at: s.sold_at ?? '', items: JSON.stringify(s.items)};\n return {json: row, pairedItem: {item: i}};\n});"
      },
      "position": [
        480,
        300
      ],
      "typeVersion": 2,
      "id": "74f3b72a-0b64-4085-b3ee-f74dd966b1d4"
    },
    {
      "name": "Save in Packing",
      "type": "n8n-nodes-base.googleSheets",
      "parameters": {
        "resource": "sheet",
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Packing",
          "mode": "name"
        },
        "options": {
          "cellFormat": "RAW"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "event_id": "={{ $json.event_id }}",
            "order_id": "={{ $json.order_id }}",
            "channel": "={{ $json.channel }}",
            "connection_id": "={{ $json.connection_id }}",
            "sold_at": "={{ $json.sold_at }}",
            "items": "={{ $json.items }}"
          },
          "matchingColumns": [
            "event_id"
          ],
          "schema": [
            {
              "id": "event_id",
              "displayName": "event_id",
              "required": false,
              "defaultMatch": true,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "order_id",
              "displayName": "order_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "channel",
              "displayName": "channel",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "connection_id",
              "displayName": "connection_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "sold_at",
              "displayName": "sold_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "items",
              "displayName": "items",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "position": [
        720,
        300
      ],
      "typeVersion": 4.7,
      "id": "380cc974-e1f3-4909-8c02-55138797d5ce"
    },
    {
      "name": "Start here",
      "type": "n8n-nodes-base.stickyNote",
      "parameters": {
        "content": "## Packing queue\nCreate a Packing tab with headers: event_id, order_id, channel, connection_id, sold_at, items, packing_status\nSelect FLUF and Google credentials and set the spreadsheet ID. Edit packing_status manually; the workflow leaves it untouched. One row per sale event, not per item. Review full orders in FLUF before shipping. Upsert by event_id is best-effort; concurrent runs can duplicate rows.\nSetup: https://fluf.io/support/connect-n8n/#packing-queue",
        "height": 260,
        "width": 720
      },
      "position": [
        240,
        -20
      ],
      "typeVersion": 1,
      "id": "323b1aa3-c32f-40e4-8930-b92edb5808e7"
    }
  ],
  "connections": {
    "FLUF event": {
      "main": [
        [
          {
            "node": "Prepare event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare event": {
      "main": [
        [
          {
            "node": "Save in Packing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  }
}
