تسجيل حضور وانصراف الموظفين ببوت تيليجرام
يرسل الموظف "دخول" أو "خروج" إلى بوت تيليجرام، ويُسجَّل كل ذلك في جدول الحضور.
كيف تعمل
المشغّل: تيليجرام — موظف يراسل البوت
- يرسل الموظف "دخول" أو "خروج" إلى البوت.
- اقرأ اسم المرسل والوقت.
- أضف صفًا إلى جدول Attendance.
- رد عليه بتأكيد والوقت.
المخطط
مشغّل تطبيق كود
الكود
كود JavaScript المستخدم في خطوات 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_.
عرض الكود (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": []
}في Make، أنشئ سيناريو جديدًا وأضف هذه الوحدات بالترتيب:
- Telegram Bot › Watch Updates
- Tools › Set variable / Iterator + Array aggregator (same logic as the Code step)
- Google Sheets › Add a Row
- 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)
- Google Sheets — Create Spreadsheet Row
- Telegram — Send Message
- الـ Zaps التي فيها أكثر من خطوتين تحتاج باقة Zapier مدفوعة.
- الـ Webhooks والفلاتر/المسارات و Code by Zapier ميزات مدفوعة في بعض باقات Zapier.
- Code by Zapier يشغّل JavaScript: أعد استخدام الكود بالأعلى، مع قراءة المدخلات من inputData بدلًا من $json.
- قد تختلف أسماء الوحدات والخطوات قليلًا مع تحديث Make و Zapier لتطبيقاتهما.
نصائح
- الأوقات تُحفظ بتوقيت UTC؛ أضف فرق التوقيت في الجدول أو في خطوة Code.
- ثبّت البوت في مجموعة الموظفين حتى لا ينساه أحد.
أتمتات مشابهة
الموارد البشرية والفريقسهل
حزمة ترحيب للموظف الجديد: بريد ودعوة لليوم الأول وتعريف بالفريق
أضف الموظف الجديد إلى جدول، فيصله بريد ترحيب ودعوة تقويم لليوم الأول، ويرحّب به الفريق على Slack.
Google Sheets → Gmail → Google Calendar → Slack3 س/شهر
الموارد البشرية والفريقسهل
أعياد ميلاد الفريق وذكرى الانضمام على Slack
كل صباح، احتفل بأعياد الميلاد وذكرى انضمام الزملاء في قناة الفريق.
Google Sheets → Slack1 س/شهر
المالية والإدارةمتوسط
سجّل مصروفاتك برسالة لبوت تيليجرام
أرسل "12.50 غداء" إلى البوت فتُحفظ فورًا في Google Sheet.
Telegram → Google Sheets3 س/شهر