احفظ مرفقات الفواتير من Gmail في Drive
الفواتير التي تصل بالبريد تُحفظ تلقائيًا في مجلد على Drive.
كيف تعمل
المشغّل: Gmail — بريد جديد يطابق "invoice has:attachment"
- راقب Gmail للرسائل التي تحتوي "invoice" ومرفقًا.
- حمّل المرفقات.
- ارفعها إلى مجلد Drive مسمّى بالشهر، مثل "Invoices/2026-09".
المخطط
مشغّل تطبيق كود
الكود
كود JavaScript المستخدم في خطوات Code، وهو مضمَّن بالفعل في القالب بالأسفل.
// Splits every attachment into its own item and gives it a sortable file name:
// 2026-09-26-supplier.com-invoice.pdf
const out = [];
for (const item of $input.all()) {
const date = new Date(item.json.date).toISOString().slice(0, 10);
const sender = item.json.from?.value?.[0]?.address || "unknown@unknown";
const domain = sender.split("@")[1];
for (const file of Object.values(item.binary || {})) {
out.push({
json: { fileName: `${date}-${domain}-${file.fileName}` },
binary: { data: file },
});
}
}
return out;ابنِها بأداتك
اختر أداتك — نفس الأتمتة، خطوة بخطوة.
انسخه والصقه مباشرة في مساحة عمل n8n (Ctrl+V)، أو حمّله واستخدم Import from File. بعد ذلك اربط حساباتك واستبدل كل قيمة تبدأ بـ YOUR_.
عرض الكود (116 سطر)
{
"name": "احفظ مرفقات الفواتير من Gmail في Drive (Flowngn)",
"nodes": [
{
"parameters": {
"content": "## احفظ مرفقات الفواتير من Gmail في Drive\nالفواتير التي تصل بالبريد تُحفظ تلقائيًا في مجلد على Drive.\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-42db-a482-bc5e476f5441",
"name": "Setup notes",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-420,
-60
]
},
{
"parameters": {
"pollTimes": {
"item": [
{
"mode": "everyHour"
}
]
},
"simple": false,
"filters": {
"q": "invoice has:attachment"
},
"options": {
"downloadAttachments": true
}
},
"id": "35c47c31-a6eb-42db-a482-bc5e476f5441",
"name": "Invoice email",
"type": "n8n-nodes-base.gmailTrigger",
"typeVersion": 1.2,
"position": [
0,
0
]
},
{
"parameters": {
"jsCode": "// Splits every attachment into its own item and gives it a sortable file name:\n// 2026-09-26-supplier.com-invoice.pdf\nconst out = [];\n\nfor (const item of $input.all()) {\n const date = new Date(item.json.date).toISOString().slice(0, 10);\n const sender = item.json.from?.value?.[0]?.address || \"unknown@unknown\";\n const domain = sender.split(\"@\")[1];\n\n for (const file of Object.values(item.binary || {})) {\n out.push({\n json: { fileName: `${date}-${domain}-${file.fileName}` },\n binary: { data: file },\n });\n }\n}\n\nreturn out;"
},
"id": "35c47c31-a6eb-42db-a482-bc5e476f5441",
"name": "Split attachments",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
300,
0
]
},
{
"parameters": {
"name": "={{ $json.fileName }}",
"driveId": {
"__rl": true,
"value": "My Drive",
"mode": "list"
},
"folderId": {
"__rl": true,
"value": "YOUR_INVOICES_FOLDER_ID",
"mode": "id"
},
"inputDataFieldName": "data",
"options": {}
},
"id": "35c47c31-a6eb-42db-a482-bc5e476f5441",
"name": "Upload to Drive",
"type": "n8n-nodes-base.googleDrive",
"typeVersion": 3,
"position": [
600,
0
]
}
],
"connections": {
"Invoice email": {
"main": [
[
{
"node": "Split attachments",
"type": "main",
"index": 0
}
]
]
},
"Split attachments": {
"main": [
[
{
"node": "Upload to Drive",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"meta": {
"templateCredsSetupCompleted": false
},
"tags": []
}في Make، أنشئ سيناريو جديدًا وأضف هذه الوحدات بالترتيب:
- Gmail › Watch Emails (search: invoice has:attachment)
- Tools › Set variable / Iterator + Array aggregator (same logic as the Code step)
- Google Drive › Upload a File
- كل تشغيل لوحدة يستهلك عمليات (operations) في Make — والباقة المجانية تتضمن حصة شهرية.
- دوال Make المدمجة (map و sum و formatDate…) تغني عن معظم خطوات Code؛ وللمنطق المعقد استخدم وحدة كود.
- قد تختلف أسماء الوحدات والخطوات قليلًا مع تحديث Make و Zapier لتطبيقاتهما.
في Zapier، أنشئ Zap جديدًا وأضف هذه الخطوات بالترتيب:
- Gmail — New Email Matching Search (invoice has:attachment)
- Code by Zapier — Run JavaScript (paste the code from the Code section)
- Google Drive — Upload File
- الـ Zaps التي فيها أكثر من خطوتين تحتاج باقة Zapier مدفوعة.
- الـ Webhooks والفلاتر/المسارات و Code by Zapier ميزات مدفوعة في بعض باقات Zapier.
- Code by Zapier يشغّل JavaScript: أعد استخدام الكود بالأعلى، مع قراءة المدخلات من inputData بدلًا من $json.
- قد تختلف أسماء الوحدات والخطوات قليلًا مع تحديث Make و Zapier لتطبيقاتهما.
نصائح
- سمِّ الملفات بصيغة التاريخ-المرسل-الاسم الأصلي لتترتب تلقائيًا.
أتمتات مشابهة
المالية والإدارةمتوسط
تقرير مؤشرات الأداء الأسبوعي بالبريد
كل يوم اثنين، يصلك ملخص قصير لأهم أرقام الأسبوع الماضي من جدولك.
Google Sheets → Gmail3 س/شهر
المالية والإدارةمتوسط
تذكيرات تلقائية بالفواتير المتأخرة
كل صباح، يصل العملاء أصحاب الفواتير المتأخرة تذكير مهذب بالبريد.
Google Sheets → Gmail4 س/شهر
المالية والإدارةمتوسط
تقرير الإيرادات الشهري بالبريد
في أول كل شهر، تصلك إيرادات Stripe للشهر الماضي مقارنة بالشهر الذي قبله.
Stripe → Gmail2 س/شهر