وكيل ذكي للمخزون على تيليجرام

اسأله "كم عباية سوداء مقاس M باقية؟" أو قل "استلمنا 40 من SKU-102"، والوكيل يقرأ جدول المخزون ويحدّثه.

وكيل ذكيمتقدم توفّر ~10 ساعة شهريًا وكلاء الذكاء الاصطناعيبواسطة فريق Flowngn

تعمل مع n8n · Make · Zapier

كيف تعمل

المشغّل: تيليجرام — تراسل البوت
  1. تسأل عن المخزون أو تبلغ عن استلام أو بيع بكلام عادي.
  2. يجد الوكيل المنتج في جدول المخزون.
  3. للتحديثات، يؤكد الكمية الجديدة معك ثم يحفظها.
  4. عندما تقل الكميات، يكتب مسودة طلب شراء للمورد.

ماذا يستطيع أن يفعل

على عكس الأتمتة الثابتة، يقرر الوكيل أي أدواته يستخدم وبأي ترتيب — ويتذكر المحادثة.

  • يجيب عن أسئلة المخزون بالاسم أو SKU أو المقاس أو اللون
  • يضيف الكميات المستلمة ويخصم المباع والتالف
  • يعرض كل ما وصل إلى حد إعادة الطلب
  • يكتب مسودات طلبات شراء للموردين في Gmail

التعليمات (System prompt)

التعليمات التي تشكّل سلوك الوكيل. موجودة بالفعل داخل قالب n8n — انسخها إلى Make أو Zapier، وعدّل أجزاء YOUR_….

التعليمات (System prompt)
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 أو غيرهما). التكلفة تعتمد على النموذج وطول المحادثة — والنموذج الصغير السريع يجعل معظم المحادثات بجزء من السنت.

المخطط

trueTIncoming messageTelegram Trigger{ }Get messageCode⑂From our team chat?IfStock agentAI AgentClaude modelAnthropic Chat Mo…◷MemorySimple MemoryGRead stockGoogle Sheets ToolGUpdate quantityGoogle Sheets ToolGDraft reorder …Gmail ToolTReply on TelegramTelegram
مشغّل تطبيق منطق كود ذكاء اصطناعي أداة للوكيل

الكود

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

Get message · عقدة 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.

ملف Workflow JSON
عرض الكود (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": []
}

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

نصائح

  • أعطِ كل منتج SKU فريدًا، فهذا يمنع الوكيل من تعديل الصف الخطأ.

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