{
  "name": "Nodbot - Gmail attachments to Yandex Disk",
  "nodes": [
    {
      "parameters": {},
      "id": "646656af-a158-4e8a-a15f-266568efaffa",
      "name": "Gmail trigger",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        0,
        260
      ]
    },
    {
      "parameters": {},
      "id": "918f72f7-b10f-4988-9ed6-db68e6d0e3c0",
      "name": "Extract attachments HTTP",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        280,
        260
      ]
    },
    {
      "parameters": {
        "jsCode": "const msg = $json;\nconst messageId = String(msg.message_id ?? msg.id ?? '').trim();\nif (!messageId) throw new Error('Gmail message_id is required for dedupe');\n\nconst from = String(msg.from ?? 'unknown').replace(/[<>:\"/\\|?*]+/g, '_').slice(0, 80);\nconst subject = String(msg.subject ?? 'no-subject').replace(/[<>:\"/\\|?*]+/g, '_').slice(0, 100);\nconst date = new Date(msg.date ?? Date.now()).toISOString().slice(0, 10);\nconst baseFolder = String(msg.folder ?? 'inbox').replace(/[^A-Za-zА-Яа-я0-9._-]+/g, '_');\n\nconst attachments = Array.isArray(msg.attachments) ? msg.attachments : [];\nreturn attachments.map((file, index) => {\n  const original = String(file.filename ?? `attachment-${index + 1}`).replace(/[<>:\"/\\|?*]+/g, '_');\n  return { json: {\n    message_id: messageId,\n    dedupe_key: `gmail:${messageId}:${original}:${file.size ?? 0}`,\n    yandex_path: `/n8n/${baseFolder}/${date}/${from}/${original}`,\n    original_filename: original,\n    mime_type: file.mimeType ?? 'application/octet-stream',\n    size: file.size ?? 0,\n    title: `${subject} — ${original}`\n  }};\n});"
      },
      "id": "7b656119-e4b9-4508-9f3d-53fccaba7cea",
      "name": "Build Yandex path Code",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        560,
        260
      ]
    },
    {
      "parameters": {},
      "id": "6167a07a-e019-4918-b7f3-b9d5233272fb",
      "name": "Upload to Yandex Disk",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        840,
        260
      ]
    },
    {
      "parameters": {},
      "id": "e91a7dbc-c4a0-42ca-9fc2-8bb78bb05d92",
      "name": "Notify result Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 2,
      "position": [
        1120,
        260
      ]
    }
  ],
  "connections": {
    "Gmail trigger": {
      "main": [
        [
          {
            "node": "Extract attachments HTTP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract attachments HTTP": {
      "main": [
        [
          {
            "node": "Build Yandex path Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Yandex path Code": {
      "main": [
        [
          {
            "node": "Upload to Yandex Disk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to Yandex Disk": {
      "main": [
        [
          {
            "node": "Notify result Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    "nodbot",
    "production",
    "template"
  ],
  "triggerCount": 1,
  "updatedAt": "2026-05-30T00:00:00.000Z",
  "versionId": "6482d5a4-8df1-49dd-bda8-a26e1fa0eb8e",
  "meta": {
    "templateCredsSetupCompleted": false
  }
}