{
  "name": "FLUF — a zero-stock review queue in Google Sheets",
  "nodes": [
    {
      "name": "FLUF event",
      "type": "n8n-nodes-fluf-connect.flufConnectTrigger",
      "parameters": {
        "event": "oos_alert"
      },
      "position": [
        240,
        300
      ],
      "typeVersion": 1,
      "id": "d03e13db-2106-42cc-9158-9b0902b3372c",
      "webhookId": "8041e15d-aa93-4250-aeea-a0aece37c11e"
    },
    {
      "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 !== \"oos_alert\" || !s.event_id || !s.listing_id) throw new Error('Use a real oos_alert event with an event_id and required fields.');\n const row = {event_id: String(s.event_id), listing_id: String(s.listing_id), channels_affected: JSON.stringify(s.channels_affected ?? []), fired_at: s.fired_at ?? ''};\n return {json: row, pairedItem: {item: i}};\n});"
      },
      "position": [
        480,
        300
      ],
      "typeVersion": 2,
      "id": "153fc982-64c9-4e47-83f6-65bd2bd945a0"
    },
    {
      "name": "Save in StockReview",
      "type": "n8n-nodes-base.googleSheets",
      "parameters": {
        "resource": "sheet",
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "StockReview",
          "mode": "name"
        },
        "options": {
          "cellFormat": "RAW"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "event_id": "={{ $json.event_id }}",
            "listing_id": "={{ $json.listing_id }}",
            "channels_affected": "={{ $json.channels_affected }}",
            "fired_at": "={{ $json.fired_at }}"
          },
          "matchingColumns": [
            "event_id"
          ],
          "schema": [
            {
              "id": "event_id",
              "displayName": "event_id",
              "required": false,
              "defaultMatch": true,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "listing_id",
              "displayName": "listing_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "channels_affected",
              "displayName": "channels_affected",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "fired_at",
              "displayName": "fired_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "position": [
        720,
        300
      ],
      "typeVersion": 4.7,
      "id": "7ff2c419-5e7a-48bc-9d0d-4ecfa03cbef1"
    },
    {
      "name": "Start here",
      "type": "n8n-nodes-base.stickyNote",
      "parameters": {
        "content": "## Zero-stock review queue\nCreate a StockReview tab with headers: event_id, listing_id, channels_affected, fired_at\nSelect FLUF and Google credentials and set the spreadsheet ID. Use these events to review sold-out or depleted stock. Quantity zero is not proof of a sale. This does not restock or delist anything. Upsert by event_id is best-effort; concurrent runs can duplicate rows.\nSetup: https://fluf.io/support/connect-n8n/#zero-stock-review",
        "height": 260,
        "width": 720
      },
      "position": [
        240,
        -20
      ],
      "typeVersion": 1,
      "id": "1e9aa1e1-fb0d-42bb-8ed4-1c1f5d9e9cfc"
    }
  ],
  "connections": {
    "FLUF event": {
      "main": [
        [
          {
            "node": "Prepare event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare event": {
      "main": [
        [
          {
            "node": "Save in StockReview",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  }
}
