{
  "id": "cVFAAkYFqpwFNMfJ",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Securely Backup Gmail Attachments to Google Drive with n8n",
  "tags": [],
  "nodes": [
    {
      "id": "d4a564d0-70aa-48c9-8a27-1e6058be4281",
      "name": "New Email Received",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -740,
        120
      ],
      "parameters": {
        "filters": {},
        "pollTimes": {
          "item": [
            {
              "hour": 12
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5db7a818-3b6f-4a05-93d4-914106758e85",
      "name": "Fetch Email Details",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -520,
        120
      ],
      "parameters": {
        "simple": false,
        "options": {
          "downloadAttachments": true,
          "dataPropertyAttachmentsPrefixName": "attachment"
        },
        "messageId": "={{ $json.id }}",
        "operation": "get"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "e4526a51-f4b7-47e7-8c0e-84aa128f066f",
      "name": "Wait for Processing",
      "type": "n8n-nodes-base.wait",
      "position": [
        -300,
        120
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "e42d60ba-4c33-4bc8-9434-dff87c3761e6",
      "name": "Process Attachment Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -80,
        120
      ],
      "parameters": {
        "jsCode": "return Object.values(items[0].binary).map(data => ({\n  binary: { data }\n}));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "8461dbf5-602f-43b7-8c58-c4f47868cf48",
      "name": "Upload to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        140,
        120
      ],
      "parameters": {
        "name": "={{ $('New Email Received').item.json.id + \"_\" + $now + \"_\" + \"backup_attachment\" }}",
        "driveId": {
          "__rl": true,
          "mode": "id",
          "value": "bgty678ikm32wedfg"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "7ujhft66uyhnoikjn234rtrgh2345tgfdsss"
        },
        "inputDataFieldName": "=data"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "f877e2d1-763d-4182-9006-973988e961fb",
      "name": "Notify via WhatsApp",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        360,
        120
      ],
      "parameters": {
        "textBody": "Your Gmail attachments have been backed up to Google Drive without any issues. You can now access them securely anytime.",
        "operation": "send",
        "phoneNumberId": "=+123498733334",
        "additionalFields": {},
        "recipientPhoneNumber": "+1234567890"
      },
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "27c8da32-b2f3-4386-a45b-226beb975584",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -780,
        -80
      ],
      "parameters": {
        "color": 4,
        "width": 180,
        "height": 420,
        "content": "Initiates the workflow on new Gmail messages"
      },
      "typeVersion": 1
    },
    {
      "id": "29568973-eeee-4692-8a3c-a49c8de824a0",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -340,
        -80
      ],
      "parameters": {
        "color": 5,
        "width": 180,
        "height": 420,
        "content": "Adds a short delay for reliable processing"
      },
      "typeVersion": 1
    },
    {
      "id": "6552b492-0ea6-48df-ae7c-b04eddfbdfb2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -120,
        -80
      ],
      "parameters": {
        "color": 3,
        "width": 180,
        "height": 420,
        "content": "Processes the attachment data"
      },
      "typeVersion": 1
    },
    {
      "id": "ad5b45dd-9f10-4d03-a3dd-57cfeeb7193b",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        -80
      ],
      "parameters": {
        "color": 2,
        "width": 180,
        "height": 420,
        "content": "Uploads the attachment to Google Drive"
      },
      "typeVersion": 1
    },
    {
      "id": "b08769f8-381d-4f07-b977-684f7e5389ed",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        -80
      ],
      "parameters": {
        "color": 6,
        "width": 180,
        "height": 420,
        "content": "Sends a WhatsApp message to confirm the backup"
      },
      "typeVersion": 1
    },
    {
      "id": "81a517bc-9401-4de4-b223-8ee6c79c09f0",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        -80
      ],
      "parameters": {
        "width": 180,
        "height": 420,
        "content": "Retrieves the new email message"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "734c09ce-bd14-4071-9959-257e6fdb9207",
  "connections": {
    "New Email Received": {
      "main": [
        [
          {
            "node": "Fetch Email Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Email Details": {
      "main": [
        [
          {
            "node": "Wait for Processing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Processing": {
      "main": [
        [
          {
            "node": "Process Attachment Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to Google Drive": {
      "main": [
        [
          {
            "node": "Notify via WhatsApp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Attachment Data": {
      "main": [
        [
          {
            "node": "Upload to Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}