Low-stock alert in Slack

Check inventory daily and warn your team before a product sells out.

Medium Saves ~3 hours/month E-commerceBy Flowngn team

Works with n8n · Make · Zapier

How it works

Trigger: Schedule — every day at 9:00
  1. Get all products and variants from Shopify.
  2. Keep only variants with inventory below your threshold (e.g. 5).
  3. If any are found, post a list to your #inventory Slack channel.

Diagram

Every day 9:00Schedule TriggerSGet all productsShopify{ }Find low stockCodeSAlert #inventorySlack
Trigger App Code

Code

JavaScript used in the Code step — already included in the template below.

Find low stock · Code node
// Lists every variant below the threshold. Returns nothing when stock is fine,
// so the Slack node only runs when there is something to report.
const THRESHOLD = 5;
const low = [];

for (const { json: product } of $input.all()) {
  for (const v of product.variants || []) {
    if (v.inventory_quantity < THRESHOLD) {
      const variant = v.title !== "Default Title" ? ` – ${v.title}` : "";
      low.push(`• ${product.title}${variant}: ${v.inventory_quantity} left`);
    }
  }
}

if (!low.length) return [];
return [{ json: { text: `⚠️ Low stock:\n${low.join("\n")}` } }];

Build it

Pick your tool — same automation, step by step.

Copy and paste straight into an n8n canvas (Ctrl+V), or download and use Import from File. Then connect your own credentials and replace every YOUR_… placeholder.

Workflow JSON
Show code (130 lines)
{
  "name": "Low-stock alert in Slack (Flowngn)",
  "nodes": [
    {
      "parameters": {
        "content": "## Low-stock alert in Slack\nCheck inventory daily and warn your team before a product sells out.\n\n**Setup**\n1. Open each node and connect your own credentials.\n2. Replace every YOUR_… placeholder.\n3. Test once, then activate.\n\nFree template from Flowngn",
        "height": 260,
        "width": 340
      },
      "id": "310be4a1-4008-4828-ad8d-e71c4a4bb1f3",
      "name": "Setup notes",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -420,
        -60
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "id": "310be4a1-4008-4828-ad8d-e71c4a4bb1f3",
      "name": "Every day 9:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "resource": "product",
        "operation": "getAll",
        "returnAll": true
      },
      "id": "310be4a1-4008-4828-ad8d-e71c4a4bb1f3",
      "name": "Get all products",
      "type": "n8n-nodes-base.shopify",
      "typeVersion": 1,
      "position": [
        300,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "// Lists every variant below the threshold. Returns nothing when stock is fine,\n// so the Slack node only runs when there is something to report.\nconst THRESHOLD = 5;\nconst low = [];\n\nfor (const { json: product } of $input.all()) {\n  for (const v of product.variants || []) {\n    if (v.inventory_quantity < THRESHOLD) {\n      const variant = v.title !== \"Default Title\" ? ` – ${v.title}` : \"\";\n      low.push(`• ${product.title}${variant}: ${v.inventory_quantity} left`);\n    }\n  }\n}\n\nif (!low.length) return [];\nreturn [{ json: { text: `⚠️ Low stock:\\n${low.join(\"\\n\")}` } }];"
      },
      "id": "310be4a1-4008-4828-ad8d-e71c4a4bb1f3",
      "name": "Find low stock",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        600,
        0
      ]
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "#inventory",
          "mode": "name"
        },
        "text": "={{ $json.text }}",
        "otherOptions": {}
      },
      "id": "310be4a1-4008-4828-ad8d-e71c4a4bb1f3",
      "name": "Alert #inventory",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [
        900,
        0
      ]
    }
  ],
  "connections": {
    "Every day 9:00": {
      "main": [
        [
          {
            "node": "Get all products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get all products": {
      "main": [
        [
          {
            "node": "Find low stock",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find low stock": {
      "main": [
        [
          {
            "node": "Alert #inventory",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}

Open in the playground to edit →

Tips

  • Store thresholds per product in a sheet if some items sell faster.

Related flows