{
  "id": "zn8PCtQ6ISmR8ptG",
  "name": "SHOPIFYINVENTORY LOW STOCK MONITOR",
  "tags": [],
  "nodes": [
    {
      "id": "a02768c5-a7d4-491a-b140-befbcd5f2c7b",
      "name": "Daily Inventory Check",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -840,
        340
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 * * *"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5b063339-70a3-4d41-a396-b3f49626ad78",
      "name": "Get All Products",
      "type": "n8n-nodes-base.shopify",
      "position": [
        -620,
        340
      ],
      "parameters": {
        "resource": "product",
        "operation": "getAll",
        "returnAll": true,
        "additionalFields": {}
      },
      "typeVersion": 1
    },
    {
      "id": "c992fedb-0c21-493f-8b0b-cbd6a7335a40",
      "name": "Filter Low Stock Items",
      "type": "n8n-nodes-base.code",
      "position": [
        -400,
        340
      ],
      "parameters": {
        "jsCode": "const lowStockThreshold = 10; // Set your threshold\nconst lowStockProducts = [];\n\nfor (const product of $input.all()) {\n  for (const variant of product.json.variants) {\n    if (variant.inventory_quantity <= lowStockThreshold && variant.inventory_quantity > 0) {\n      lowStockProducts.push({\n        product_title: product.json.title,\n        variant_title: variant.title,\n        sku: variant.sku,\n        current_stock: variant.inventory_quantity,\n        product_id: product.json.id,\n        variant_id: variant.id\n      });\n    }\n  }\n}\n\nreturn lowStockProducts.map(item => ({ json: item }));"
      },
      "typeVersion": 2
    },
    {
      "id": "ba2f6f7f-540a-4d48-99a5-75cb28c88753",
      "name": "Check if Alerts Needed",
      "type": "n8n-nodes-base.if",
      "position": [
        -180,
        340
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "condition-001",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $('Filter Low Stock Items').all().length }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "f20e4aa3-588b-4da8-b0d4-e097711f1747",
      "name": "Format Alert Message",
      "type": "n8n-nodes-base.set",
      "position": [
        40,
        340
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"alert_message\": \"\ud83d\udea8 *Low Stock Alert*\\n\\nThe following items are running low:\\n\\n{{ $('Filter Low Stock Items').all().map(item => `\u2022 ${item.json.product_title} (${item.json.variant_title}): ${item.json.current_stock} left`).join('\\n') }}\",\n  \"products_count\": \"{{ $('Filter Low Stock Items').all().length }}\"\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "3ddc4707-1295-41cd-a874-f0601f66c995",
      "name": "Send Inventory Alert",
      "type": "n8n-nodes-base.slack",
      "position": [
        260,
        340
      ],
      "parameters": {
        "text": "={{ $json.alert_message }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C1234567890",
          "cachedResultName": "inventory"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "typeVersion": 2.3
    },
    {
      "id": "9b6e400f-d16d-44b3-8ee2-d68ac6a89fc3",
      "name": "Workflow Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1200,
        160
      ],
      "parameters": {
        "width": 320,
        "height": 400,
        "content": "## \ud83d\udce6 INVENTORY LOW STOCK MONITOR\n\n**Author: DAVID OLUSOLA**\n\nWORKFLOW PURPOSE:\nAutomatically monitor Shopify inventory levels and alert when products are running low\n\nSETUP REQUIREMENTS:\n- Shopify store with product inventory tracking\n- Slack channel for alerts (#inventory)\n- Define low stock threshold (default: 10 units)\n\nNODES FLOW:\n1. Schedule Trigger (daily 9 AM check)\n2. Shopify (get all products)\n3. Code Node (filter low stock items)\n4. If Node (check if any alerts needed)\n5. Edit Fields (format alert message)\n6. Slack (send inventory alert)"
      },
      "typeVersion": 1
    },
    {
      "id": "2b68b93f-b4a8-49d6-bb8d-87f4028cf81c",
      "name": "Features & Config",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 6,
        "width": 300,
        "height": 280,
        "content": "**KEY FEATURES**:\n\u2705 Daily automated inventory checks\n\u2705 Customizable stock thresholds\n\u2705 Multi-variant product support\n\u2705 Detailed low stock reporting\n\u2705 Proactive restocking alerts\n\nCONFIGURATION NOTES:\n- Adjust lowStockThreshold variable in Code node\n- Modify schedule timing as needed\n- Include SKU numbers for easy reordering\n- Can add email alerts instead of/in addition to Slack"
      },
      "typeVersion": 1
    },
    {
      "id": "9c1250d3-08bf-47da-bdf2-40b95bcb584d",
      "name": "Business Value",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        500
      ],
      "parameters": {
        "color": 7,
        "width": 260,
        "height": 200,
        "content": "**BUSINESS VALUE**:\n\ud83d\udeab Prevent stockouts\n\ud83d\udcb0 Maintain sales revenue\n\ud83d\udcca Better inventory management\n\u23f0 Proactive restocking\n\nTIME TO BUILD: 20 minutes\nDIFFICULTY: Intermediate\nROI: High - prevents lost sales"
      },
      "typeVersion": 1
    },
    {
      "id": "9fbe2564-05df-4453-9961-fe98d0873eb4",
      "name": "Threshold Guide",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        80
      ],
      "parameters": {
        "color": 5,
        "width": 280,
        "height": 240,
        "content": "**THRESHOLD CUSTOMIZATION**:\nModify the lowStockThreshold variable in the Code node:\n\nconst lowStockThreshold = 10;\n\nChange 10 to your desired threshold:\n- 5 for fast-moving items\n- 20 for slow-moving items\n- 50 for high-volume products"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "50ae8a36-065f-4c4f-a27d-f1970faaae12",
  "connections": {
    "Get All Products": {
      "main": [
        [
          {
            "node": "Filter Low Stock Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Alert Message": {
      "main": [
        [
          {
            "node": "Send Inventory Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Inventory Check": {
      "main": [
        [
          {
            "node": "Get All Products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Alerts Needed": {
      "main": [
        [
          {
            "node": "Format Alert Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Low Stock Items": {
      "main": [
        [
          {
            "node": "Check if Alerts Needed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}