AutomationFlowsEmail & Gmail › Gmail Attachments to Google Drive Folders

Gmail Attachments to Google Drive Folders

Original n8n title: Organize Email Attachments From Gmail to Structured Google Drive Folders

ByMichael Gullo @mgullo on n8n.io

This workflow is designed to automate the process of handling emails with binary attachments. It triggers when a new email arrives in a specified Gmail account (or can be configured with a similar email trigger) and is set to download any binary attachments. The workflow then…

Event trigger★★★★☆ complexity8 nodesGmail TriggerGoogle DriveGmail
Email & Gmail Trigger: Event Nodes: 8 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #4977 — we link there as the canonical source.

This workflow follows the Gmail → Gmail Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "9rIwaQlNKOLLs6Yi",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Email to Folder",
  "tags": [],
  "nodes": [
    {
      "id": "f0c308d6-9347-441b-a78b-b25de884f942",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -340,
        220
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {
          "downloadAttachments": true
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "54a70814-0185-420b-a7e7-66ed811fae3c",
      "name": "Google Drive1",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1040,
        220
      ],
      "parameters": {
        "name": "={{ $json.id }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $node[\"Create Folder\"].json.id }}"
        },
        "inputDataFieldName": "={{ $binary.keys()[0] }}"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "435c21d8-7d23-447d-a081-a4991ba42a41",
      "name": "Create Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        380,
        160
      ],
      "parameters": {
        "name": "=Motion - {{ $node[\"Gmail Trigger\"].json.subject || \"Untitled\" }} - {{ $now }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root",
          "cachedResultName": "/ (Root folder)"
        },
        "resource": "folder"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "executeOnce": true,
      "typeVersion": 3
    },
    {
      "id": "3acb5376-3528-4a30-9612-67bd1a509adc",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        -20
      ],
      "parameters": {
        "color": 6,
        "width": 1700,
        "height": 660,
        "content": "Take PDF from Email and create a new folder with PDF "
      },
      "typeVersion": 1
    },
    {
      "id": "e4aef0db-b072-4dc7-80e0-cd3658555bda",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "position": [
        -120,
        220
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "87e927b3-4f28-4843-b2d0-cf7269437fca",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $('Gmail Trigger').item.binary}}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4218230f-ccd0-4b8b-a4b3-54749ce8a738",
      "name": "Gmail1",
      "type": "n8n-nodes-base.gmail",
      "position": [
        100,
        220
      ],
      "parameters": {
        "simple": false,
        "options": {
          "downloadAttachments": true
        },
        "messageId": "={{ $node[\"Gmail Trigger\"].json.id }}",
        "operation": "get"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "833ab358-ce62-4acf-847e-0251bfb8e123",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        700,
        220
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3.1
    },
    {
      "id": "55de30ff-40de-4b51-b5bd-0c00fbba80be",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        380,
        360
      ],
      "parameters": {
        "options": {
          "includeBinary": true
        },
        "fieldToSplitOut": "$binary"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "5d7c63e5-67f2-483d-8ebe-0c90967a1137",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Google Drive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Gmail1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail1": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          },
          {
            "node": "Create Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Create Folder": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive1": {
      "main": [
        []
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow is designed to automate the process of handling emails with binary attachments. It triggers when a new email arrives in a specified Gmail account (or can be configured with a similar email trigger) and is set to download any binary attachments. The workflow then…

Source: https://n8n.io/workflows/4977/ — original creator credit. Request a take-down →

More Email & Gmail workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Email & Gmail

This template is built to be customized for your specific needs. This template has the core logic and n8n node specific references sorted to work with dynamic file names throughout the workflow. Store

Gmail, Slack, Gmail Trigger +3
Email & Gmail

This is an elite enterprise-grade solution for Talent Acquisition and HR Ops teams. It automates the high-volume task of resume screening by transforming unstructured PDF applications into structured

N8N Nodes Htmlcsstopdf, Postgres, HubSpot +4
Email & Gmail

📩🤖 This workflow automatically processes emails received in Gmail, extracts their attachments, and organizes them into specific folders in Google Drive based on the sender's email address.

Gmail Trigger, Google Drive, Execute Workflow Trigger +1
Email & Gmail

Teams that receive documents via email (invoices, receipts, contracts) and want structured data automatically extracted and added to a spreadsheet - without manual data entry.

Gmail Trigger, Gmail, N8N Nodes Docupipe +2
Email & Gmail

Freelancers, finance teams, and small businesses that receive invoice PDFs by email and want them automatically saved to Google Drive and logged in Google Sheets—without manual downloading or copy-pas

Gmail Trigger, Google Drive, Google Sheets +1