تسجيل حضور وانصراف الموظفين ببوت تيليجرام

يرسل الموظف "دخول" أو "خروج" إلى بوت تيليجرام، ويُسجَّل كل ذلك في جدول الحضور.

سهل توفّر ~4 ساعة شهريًا الموارد البشرية والفريقبواسطة فريق Flowngn

تعمل مع n8n · Make · Zapier

كيف تعمل

المشغّل: تيليجرام — موظف يراسل البوت
  1. يرسل الموظف "دخول" أو "خروج" إلى البوت.
  2. اقرأ اسم المرسل والوقت.
  3. أضف صفًا إلى جدول Attendance.
  4. رد عليه بتأكيد والوقت.

المخطط

TMessage to botTelegram Trigger{ }Read check-inCodeGLog attendanceGoogle SheetsTConfirmTelegram
مشغّل تطبيق كود

الكود

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

Read check-in · عقدة Code
// Turns "in", "out", "دخول" or "خروج" sent to the bot into an attendance row.
const msg = $input.first().json.message;
const text = String(msg?.text || "").trim().toLowerCase();

const IN = ["in", "check in", "دخول", "حضور"];
const OUT = ["out", "check out", "خروج", "انصراف"];
const action = IN.includes(text) ? "in" : OUT.includes(text) ? "out" : null;
if (!action) return [];

const at = new Date(msg.date * 1000);
return [{
  json: {
    chatId: msg.chat.id,
    telegram_id: msg.from.id,
    name: [msg.from.first_name, msg.from.last_name].filter(Boolean).join(" "),
    action,
    date: at.toISOString().slice(0, 10),
    time: at.toISOString().slice(11, 16),
  },
}];

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

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

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

ملف Workflow JSON
عرض الكود (144 سطر)
{
  "name": "تسجيل حضور وانصراف الموظفين ببوت تيليجرام (Flowngn)",
  "nodes": [
    {
      "parameters": {
        "content": "## تسجيل حضور وانصراف الموظفين ببوت تيليجرام\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": "3da33d1f-b8e3-42d1-aace-213b83d434e0",
      "name": "Setup notes",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -420,
        -60
      ]
    },
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "id": "3da33d1f-b8e3-42d1-aace-213b83d434e0",
      "name": "Message to bot",
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        0,
        0
      ],
      "webhookId": "3da33d1f-b8e3-42d1-aace-213b83d434e0"
    },
    {
      "parameters": {
        "jsCode": "// Turns \"in\", \"out\", \"دخول\" or \"خروج\" sent to the bot into an attendance row.\nconst msg = $input.first().json.message;\nconst text = String(msg?.text || \"\").trim().toLowerCase();\n\nconst IN = [\"in\", \"check in\", \"دخول\", \"حضور\"];\nconst OUT = [\"out\", \"check out\", \"خروج\", \"انصراف\"];\nconst action = IN.includes(text) ? \"in\" : OUT.includes(text) ? \"out\" : null;\nif (!action) return [];\n\nconst at = new Date(msg.date * 1000);\nreturn [{\n  json: {\n    chatId: msg.chat.id,\n    telegram_id: msg.from.id,\n    name: [msg.from.first_name, msg.from.last_name].filter(Boolean).join(\" \"),\n    action,\n    date: at.toISOString().slice(0, 10),\n    time: at.toISOString().slice(11, 16),\n  },\n}];"
      },
      "id": "3da33d1f-b8e3-42d1-aace-213b83d434e0",
      "name": "Read check-in",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        300,
        0
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Attendance",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "date": "={{ $json.date }}",
            "time": "={{ $json.time }}",
            "name": "={{ $json.name }}",
            "telegram_id": "={{ $json.telegram_id }}",
            "action": "={{ $json.action }}"
          }
        },
        "options": {}
      },
      "id": "3da33d1f-b8e3-42d1-aace-213b83d434e0",
      "name": "Log attendance",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        600,
        0
      ]
    },
    {
      "parameters": {
        "chatId": "={{ $('Read check-in').item.json.chatId }}",
        "text": "=✅ {{ $('Read check-in').item.json.action === 'in' ? 'Checked in' : 'Checked out' }} at {{ $('Read check-in').item.json.time }} UTC",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "3da33d1f-b8e3-42d1-aace-213b83d434e0",
      "name": "Confirm",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        900,
        0
      ]
    }
  ],
  "connections": {
    "Message to bot": {
      "main": [
        [
          {
            "node": "Read check-in",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read check-in": {
      "main": [
        [
          {
            "node": "Log attendance",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log attendance": {
      "main": [
        [
          {
            "node": "Confirm",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}

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

نصائح

  • الأوقات تُحفظ بتوقيت UTC؛ أضف فرق التوقيت في الجدول أو في خطوة Code.
  • ثبّت البوت في مجموعة الموظفين حتى لا ينساه أحد.

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