احفظ مرفقات الفواتير من Gmail في Drive

الفواتير التي تصل بالبريد تُحفظ تلقائيًا في مجلد على Drive.

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

تعمل مع n8n · Make · Zapier

كيف تعمل

المشغّل: Gmail — بريد جديد يطابق "invoice has:attachment"
  1. راقب Gmail للرسائل التي تحتوي "invoice" ومرفقًا.
  2. حمّل المرفقات.
  3. ارفعها إلى مجلد Drive مسمّى بالشهر، مثل "Invoices/2026-09".

المخطط

GInvoice emailGmail Trigger{ }Split attachmentsCodeGUpload to DriveGoogle Drive
مشغّل تطبيق كود

الكود

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

Split attachments · عقدة 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_.

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

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

نصائح

  • سمِّ الملفات بصيغة التاريخ-المرسل-الاسم الأصلي لتترتب تلقائيًا.

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