تنبيه نقص المخزون في Slack

افحص المخزون يوميًا ونبّه فريقك قبل نفاد أي منتج.

متوسط توفّر ~3 ساعة شهريًا التجارة الإلكترونيةبواسطة فريق Flowngn

تعمل مع n8n · Make · Zapier

كيف تعمل

المشغّل: جدول زمني — كل يوم الساعة 9:00
  1. اجلب كل المنتجات ونسخها من Shopify.
  2. احتفظ فقط بالنسخ التي مخزونها أقل من الحد (مثل 5).
  3. إن وُجدت، أرسل قائمتها إلى قناة #inventory في Slack.

المخطط

Every day 9:00Schedule TriggerSGet all productsShopify{ }Find low stockCodeSAlert #inventorySlack
مشغّل تطبيق كود

الكود

كود JavaScript المستخدم في خطوات Code، وهو مضمَّن بالفعل في القالب بالأسفل.

Find low stock · عقدة Code
// 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")}` } }];

ابنِها بأداتك

اختر أداتك — نفس الأتمتة، خطوة بخطوة.

انسخه والصقه مباشرة في مساحة عمل n8n (Ctrl+V)، أو حمّله واستخدم Import from File. بعد ذلك اربط حساباتك واستبدل كل قيمة تبدأ بـ YOUR_.

ملف Workflow JSON
عرض الكود (130 سطر)
{
  "name": "تنبيه نقص المخزون في Slack (Flowngn)",
  "nodes": [
    {
      "parameters": {
        "content": "## تنبيه نقص المخزون في Slack\nافحص المخزون يوميًا ونبّه فريقك قبل نفاد أي منتج.\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": []
}

← افتحها في ساحة التجربة لتعديلها

نصائح

  • احفظ حدًا مختلفًا لكل منتج في جدول إذا كانت بعض المنتجات تُباع أسرع.

أتمتات مشابهة