{
  "name": "Gmail Attachments to Google Drive",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [{ "mode": "everyMinute" }]
        },
        "filters": {
          "readStatus": "unread",
          "sender": "",
          "subject": ""
        },
        "options": {
          "downloadAttachments": true
        }
      },
      "id": "gad00001-0001-4000-8000-000000000001",
      "name": "Watch Gmail for Attachments",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "cond1",
              "leftValue": "={{ $json.attachments.length }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "gad00001-0002-4000-8000-000000000002",
      "name": "Has Attachments",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "operation": "upload",
        "name": "={{ $json.attachments[0].name }}",
        "driveId": { "__rl": true, "mode": "list", "value": "My Drive" },
        "folderId": { "__rl": true, "mode": "list", "value": "root" },
        "binaryData": true,
        "binaryPropertyName": "attachment_0",
        "options": {
          "ocrLanguage": ""
        }
      },
      "id": "gad00001-0003-4000-8000-000000000003",
      "name": "Upload to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [680, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "field1",
              "name": "status",
              "value": "uploaded",
              "type": "string"
            },
            {
              "id": "field2",
              "name": "fileName",
              "value": "={{ $json.name }}",
              "type": "string"
            },
            {
              "id": "field3",
              "name": "driveFileId",
              "value": "={{ $json.id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "gad00001-0004-4000-8000-000000000004",
      "name": "Record Upload Result",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [900, 300]
    }
  ],
  "connections": {
    "Watch Gmail for Attachments": {
      "main": [[{ "node": "Has Attachments", "type": "main", "index": 0 }]]
    },
    "Has Attachments": {
      "main": [
        [{ "node": "Upload to Google Drive", "type": "main", "index": 0 }],
        []
      ]
    },
    "Upload to Google Drive": {
      "main": [[{ "node": "Record Upload Result", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
