وكيل ذكي للمخزون على تيليجرام
اسأله "كم عباية سوداء مقاس M باقية؟" أو قل "استلمنا 40 من SKU-102"، والوكيل يقرأ جدول المخزون ويحدّثه.
كيف تعمل
- تسأل عن المخزون أو تبلغ عن استلام أو بيع بكلام عادي.
- يجد الوكيل المنتج في جدول المخزون.
- للتحديثات، يؤكد الكمية الجديدة معك ثم يحفظها.
- عندما تقل الكميات، يكتب مسودة طلب شراء للمورد.
ماذا يستطيع أن يفعل
على عكس الأتمتة الثابتة، يقرر الوكيل أي أدواته يستخدم وبأي ترتيب — ويتذكر المحادثة.
- يجيب عن أسئلة المخزون بالاسم أو SKU أو المقاس أو اللون
- يضيف الكميات المستلمة ويخصم المباع والتالف
- يعرض كل ما وصل إلى حد إعادة الطلب
- يكتب مسودات طلبات شراء للموردين في Gmail
التعليمات (System prompt)
التعليمات التي تشكّل سلوك الوكيل. موجودة بالفعل داخل قالب n8n — انسخها إلى Make أو Zapier، وعدّل أجزاء YOUR_….
You are the stock assistant for YOUR_SHOP on Telegram. You talk to our own team. Reply in their language (Arabic or English), short and clear. Today is {{ $now.toFormat('d LLLL yyyy') }}.
Tools:
- "Read stock": the Stock sheet (sku, product, size, colour, quantity, reorder_level, supplier, supplier_email). Always read it before answering or changing anything.
- "Update quantity": sets the new quantity for one SKU. Use only after the person confirms the SKU and the new number.
- "Draft reorder email": creates a Gmail draft to a supplier (never sends).
You can:
- Answer "how many … are left?" by product, SKU, size or colour.
- Record stock received, sold, returned or damaged: work out the new quantity from the current one, say "SKU-102: 12 → 52. Save?", and update only after a yes.
- List items at or below their reorder level, and draft reorder emails grouped by supplier when asked.
Rules:
- If more than one row matches, list them and ask which one. Never guess the SKU.
- Never set a negative quantity; ask the person to check instead.
- Never invent products, quantities or supplier details.قواعد الأمان
مدمجة في التعليمات والأدوات:
- يؤكد كل تعديل قبل حفظه
- يرد فقط على محادثة فريقك على تيليجرام
- يكتب مسودات للموردين ولا يرسلها
يستخدم مفتاح الذكاء الاصطناعي الخاص بك (Claude أو OpenAI أو غيرهما). التكلفة تعتمد على النموذج وطول المحادثة — والنموذج الصغير السريع يجعل معظم المحادثات بجزء من السنت.
المخطط
الكود
كود JavaScript المستخدم في خطوات Code، وهو مضمَّن بالفعل في القالب بالأسفل.
// Keeps only text messages and pulls out who sent it and what they asked.
const msg = $input.first().json.message;
if (!msg?.text) return [];
return [{
json: {
chatId: msg.chat.id,
userId: msg.from.id,
name: [msg.from.first_name, msg.from.last_name].filter(Boolean).join(" "),
question: msg.text,
},
}];ابنِها بأداتك
اختر أداتك — نفس الأتمتة، خطوة بخطوة.
انسخه والصقه مباشرة في مساحة عمل n8n (Ctrl+V)، أو حمّله واستخدم Import from File. بعد ذلك اربط حساباتك واستبدل كل قيمة تبدأ بـ YOUR_. خطوات الذكاء الاصطناعي تستخدم نموذج Claude، ويمكنك استبداله بـ OpenAI أو Gemini أو Ollama.
عرض الكود (341 سطر)
{
"name": "وكيل ذكي للمخزون على تيليجرام (Flowngn)",
"nodes": [
{
"parameters": {
"content": "## وكيل ذكي للمخزون على تيليجرام\nاسأله \"كم عباية سوداء مقاس M باقية؟\" أو قل \"استلمنا 40 من SKU-102\"، والوكيل يقرأ جدول المخزون ويحدّثه.\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": "35c47c31-a6eb-4039-a611-85b8a1b7b74a",
"name": "Setup notes",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-420,
-60
]
},
{
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"id": "35c47c31-a6eb-4039-a611-85b8a1b7b74a",
"name": "Incoming message",
"type": "n8n-nodes-base.telegramTrigger",
"typeVersion": 1.1,
"position": [
0,
0
],
"webhookId": "35c47c31-a6eb-4039-a611-85b8a1b7b74a"
},
{
"parameters": {
"jsCode": "// Keeps only text messages and pulls out who sent it and what they asked.\nconst msg = $input.first().json.message;\nif (!msg?.text) return [];\n\nreturn [{\n json: {\n chatId: msg.chat.id,\n userId: msg.from.id,\n name: [msg.from.first_name, msg.from.last_name].filter(Boolean).join(\" \"),\n question: msg.text,\n },\n}];"
},
"id": "35c47c31-a6eb-4039-a611-85b8a1b7b74a",
"name": "Get message",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
300,
0
]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "loose"
},
"conditions": [
{
"id": "c1",
"leftValue": "={{ String($json.chatId) }}",
"rightValue": "YOUR_TEAM_CHAT_ID",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "35c47c31-a6eb-4039-a611-85b8a1b7b74a",
"name": "From our team chat?",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
600,
0
]
},
{
"parameters": {
"promptType": "define",
"text": "={{ $('Get message').item.json.question }}",
"options": {
"systemMessage": "=You are the stock assistant for YOUR_SHOP on Telegram. You talk to our own team. Reply in their language (Arabic or English), short and clear. Today is {{ $now.toFormat('d LLLL yyyy') }}.\n\nTools:\n- \"Read stock\": the Stock sheet (sku, product, size, colour, quantity, reorder_level, supplier, supplier_email). Always read it before answering or changing anything.\n- \"Update quantity\": sets the new quantity for one SKU. Use only after the person confirms the SKU and the new number.\n- \"Draft reorder email\": creates a Gmail draft to a supplier (never sends).\n\nYou can:\n- Answer \"how many … are left?\" by product, SKU, size or colour.\n- Record stock received, sold, returned or damaged: work out the new quantity from the current one, say \"SKU-102: 12 → 52. Save?\", and update only after a yes.\n- List items at or below their reorder level, and draft reorder emails grouped by supplier when asked.\n\nRules:\n- If more than one row matches, list them and ask which one. Never guess the SKU.\n- Never set a negative quantity; ask the person to check instead.\n- Never invent products, quantities or supplier details."
}
},
"id": "35c47c31-a6eb-4039-a611-85b8a1b7b74a",
"name": "Stock agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.9,
"position": [
900,
0
]
},
{
"parameters": {
"model": {
"__rl": true,
"value": "claude-sonnet-5",
"mode": "list"
},
"options": {}
},
"id": "35c47c31-a6eb-4039-a611-85b8a1b7b74a",
"name": "Claude model",
"type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
"typeVersion": 1.3,
"position": [
560,
220
]
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "={{ $('Get message').item.json.chatId }}",
"contextWindowLength": 10
},
"id": "35c47c31-a6eb-4039-a611-85b8a1b7b74a",
"name": "Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.3,
"position": [
730,
220
]
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "Returns the Stock sheet: sku, product, size, colour, quantity, reorder_level, supplier, supplier_email.",
"operation": "read",
"documentId": {
"__rl": true,
"value": "YOUR_SPREADSHEET_ID",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": "Stock",
"mode": "name"
},
"options": {}
},
"id": "35c47c31-a6eb-4039-a611-85b8a1b7b74a",
"name": "Read stock",
"type": "n8n-nodes-base.googleSheetsTool",
"typeVersion": 4.5,
"position": [
900,
220
]
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "Sets the new quantity for one SKU, after the person confirms.",
"operation": "update",
"documentId": {
"__rl": true,
"value": "YOUR_SPREADSHEET_ID",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": "Stock",
"mode": "name"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"sku": "={{ $fromAI('sku', \"The exact SKU\", 'string') }}",
"quantity": "={{ $fromAI('quantity', \"The new quantity\", 'number') }}"
},
"matchingColumns": [
"sku"
]
},
"options": {}
},
"id": "35c47c31-a6eb-4039-a611-85b8a1b7b74a",
"name": "Update quantity",
"type": "n8n-nodes-base.googleSheetsTool",
"typeVersion": 4.5,
"position": [
1070,
220
]
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "Creates a Gmail draft purchase order to a supplier (never sends).",
"resource": "draft",
"operation": "create",
"subject": "={{ $fromAI('subject', \"Email subject\", 'string') }}",
"message": "={{ $fromAI('body', \"Email body listing SKUs, products and quantities to reorder\", 'string') }}",
"options": {
"sendTo": "={{ $fromAI('to', \"The supplier's email from the Stock sheet\", 'string') }}"
}
},
"id": "35c47c31-a6eb-4039-a611-85b8a1b7b74a",
"name": "Draft reorder email",
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
1240,
220
]
},
{
"parameters": {
"chatId": "={{ $('Get message').item.json.chatId }}",
"text": "={{ $json.output }}",
"additionalFields": {
"appendAttribution": false
}
},
"id": "35c47c31-a6eb-4039-a611-85b8a1b7b74a",
"name": "Reply on Telegram",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
1200,
0
]
}
],
"connections": {
"Incoming message": {
"main": [
[
{
"node": "Get message",
"type": "main",
"index": 0
}
]
]
},
"Get message": {
"main": [
[
{
"node": "From our team chat?",
"type": "main",
"index": 0
}
]
]
},
"From our team chat?": {
"main": [
[
{
"node": "Stock agent",
"type": "main",
"index": 0
}
]
]
},
"Stock agent": {
"main": [
[
{
"node": "Reply on Telegram",
"type": "main",
"index": 0
}
]
]
},
"Claude model": {
"ai_languageModel": [
[
{
"node": "Stock agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Memory": {
"ai_memory": [
[
{
"node": "Stock agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Read stock": {
"ai_tool": [
[
{
"node": "Stock agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Update quantity": {
"ai_tool": [
[
{
"node": "Stock agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Draft reorder email": {
"ai_tool": [
[
{
"node": "Stock agent",
"type": "ai_tool",
"index": 0
}
]
]
}
},
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"meta": {
"templateCredsSetupCompleted": false
},
"tags": []
}في Make، أنشئ سيناريو جديدًا وأضف هذه الوحدات بالترتيب:
- Telegram Bot › Watch Updates
- Tools › Set variable / Iterator + Array aggregator (same logic as the Code step)
- Filter on the next route: “From our team chat?”
- إذا نعمMake AI Agents › Run an agent — give it these tools: “Read stock” (Google Sheets), “Update quantity” (Google Sheets), “Draft reorder email” (Gmail); paste the system prompt as the agent's instructions
- إذا نعمTelegram Bot › Send a Text Message or a Reply
- كل تشغيل لوحدة يستهلك عمليات (operations) في Make — والباقة المجانية تتضمن حصة شهرية.
- دوال Make المدمجة (map و sum و formatDate…) تغني عن معظم خطوات Code؛ وللمنطق المعقد استخدم وحدة كود.
- قد تختلف أسماء الوحدات والخطوات قليلًا مع تحديث Make و Zapier لتطبيقاتهما.
في Zapier، أنشئ Zap جديدًا وأضف هذه الخطوات بالترتيب:
- Telegram — New Message
- Code by Zapier — Run JavaScript (paste the code from the Code section)
- Filter by Zapier: “From our team chat?”
- إذا نعمZapier Agents — create an agent (or AI by Zapier for a single step) — give it these tools: “Read stock” (Google Sheets), “Update quantity” (Google Sheets), “Draft reorder email” (Gmail); paste the system prompt as the agent's instructions
- إذا نعمTelegram — Send Message
- الـ Zaps التي فيها أكثر من خطوتين تحتاج باقة Zapier مدفوعة.
- الـ Webhooks والفلاتر/المسارات و Code by Zapier ميزات مدفوعة في بعض باقات Zapier.
- Code by Zapier يشغّل JavaScript: أعد استخدام الكود بالأعلى، مع قراءة المدخلات من inputData بدلًا من $json.
- قد تختلف أسماء الوحدات والخطوات قليلًا مع تحديث Make و Zapier لتطبيقاتهما.
نصائح
- أعطِ كل منتج SKU فريدًا، فهذا يمنع الوكيل من تعديل الصف الخطأ.
أتمتات مشابهة
وكيل ذكي لإدارة المبيعات على تيليجرام
فريق مبيعاتك يضيف العملاء ويسجّل المكالمات ويسأل "مين أكلّم النهارده؟" بكلام عادي على تيليجرام.
وكيل ذكاء اصطناعي لخدمة العملاء
وكيل محادثة يجيب من أسئلتك الشائعة، ويبحث عن الطلبات، ويحوّل الحالات الصعبة إلى موظف.
وكيل مبيعات ذكي على واتساب (بالعربية)
يبيع على واتساب بلهجة العميل: يراجع منتجاتك، ويجيب الأسئلة، ويأخذ طلبات الدفع عند الاستلام.