تنبيه نقص المخزون في Slack
افحص المخزون يوميًا ونبّه فريقك قبل نفاد أي منتج.
كيف تعمل
المشغّل: جدول زمني — كل يوم الساعة 9:00
- اجلب كل المنتجات ونسخها من Shopify.
- احتفظ فقط بالنسخ التي مخزونها أقل من الحد (مثل 5).
- إن وُجدت، أرسل قائمتها إلى قناة #inventory في Slack.
المخطط
مشغّل تطبيق كود
الكود
كود JavaScript المستخدم في خطوات 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_.
عرض الكود (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": []
}في Make، أنشئ سيناريو جديدًا وأضف هذه الوحدات بالترتيب:
- Schedule the scenario: Every day 9:00
- Shopify › Search Products
- Tools › Set variable / Iterator + Array aggregator (same logic as the Code step)
- Slack › Create a Message
- كل تشغيل لوحدة يستهلك عمليات (operations) في Make — والباقة المجانية تتضمن حصة شهرية.
- دوال Make المدمجة (map و sum و formatDate…) تغني عن معظم خطوات Code؛ وللمنطق المعقد استخدم وحدة كود.
- قد تختلف أسماء الوحدات والخطوات قليلًا مع تحديث Make و Zapier لتطبيقاتهما.
في Zapier، أنشئ Zap جديدًا وأضف هذه الخطوات بالترتيب:
- Schedule by Zapier — Every day 9:00
- Code by Zapier — fetch products via the Shopify API
- Code by Zapier — Run JavaScript (paste the code from the Code section)
- Slack — Send Channel Message
- الـ Zaps التي فيها أكثر من خطوتين تحتاج باقة Zapier مدفوعة.
- الـ Webhooks والفلاتر/المسارات و Code by Zapier ميزات مدفوعة في بعض باقات Zapier.
- Code by Zapier يشغّل JavaScript: أعد استخدام الكود بالأعلى، مع قراءة المدخلات من inputData بدلًا من $json.
- قد تختلف أسماء الوحدات والخطوات قليلًا مع تحديث Make و Zapier لتطبيقاتهما.
نصائح
- احفظ حدًا مختلفًا لكل منتج في جدول إذا كانت بعض المنتجات تُباع أسرع.
أتمتات مشابهة
التجارة الإلكترونيةسهل
تنبيهات الاسترداد لمتجرك
تنبيه في Slack بالمبلغ والسبب عند كل عملية استرداد.
Shopify → Slack1 س/شهر
التجارة الإلكترونيةمتوسط
ملخص مبيعات Shopify اليومي على واتساب
كل صباح، يصلك عدد طلبات الأمس وإجمالي الإيرادات على واتساب.
Shopify → WhatsApp3 س/شهر
التجارة الإلكترونيةسهل
سجّل كل طلب جديد في Google Sheets
كل طلب جديد في Shopify يصبح صفًا في جدول يمكنك تصفيته ومشاركته.
Shopify → Google Sheets4 س/شهر