Automated Gmail Attachment Archiving to Google Drive
detail.loadingPreview
This n8n workflow automates the crucial task of organizing email attachments. It monitors a designated Gmail label, downloads attachments, and neatly stores them in a dynamic folder structure within Google Drive, ensuring effortless document retrieval and management.
About This Workflow
This powerful n8n workflow streamlines your document management by automatically processing incoming Gmail attachments. It intelligently scans emails labeled for processing, extracts all attachments, and then organizes them into a structured Google Drive hierarchy. The workflow dynamically creates folders based on company names (which are typically retrieved from an external data source like Google Sheets) and the email's arrival date (formatted as YYYY/MM), ensuring a consistent and easily navigable archive. Say goodbye to manual downloading and filing, and keep your important documents perfectly categorized with minimal effort.
Key Features
- Gmail Label Monitoring: Automatically triggers upon receiving emails with a specified Gmail label.
- Attachment Extraction: Downloads all attachments from relevant emails.
- Dynamic Folder Creation: Intelligently creates a nested Google Drive folder structure, such as
Parent_Folder/Company_Name/YYYY/MM/. - Duplicate Prevention: Checks for existing folders at each level and creates new ones only if they don't already exist.
- Individual Attachment Handling: Processes multiple attachments from a single email as separate items for organized storage.
How To Use
- Gmail Trigger (
c27b0a9d-8ee2-4eae-963c-14256ffae0b8): Configure the node with your Gmail account credentials. Infilters, specify thelabelIds(e.g., "Label_2") that will trigger this workflow. Adjust thepollTimesto set how often n8n checks for new emails. - Get Gmail Details (
3eac8c53-1b20-4511-9f2a-f5e838ca0fa0): Link your Gmail account credentials. Ensure themessageIdparameter correctly references the output from the 'Gmail Trigger' (e.g.,={{ $('Gmail Trigger').item.json.id }}). Most importantly, enabledownloadAttachmentswithin theoptionsto retrieve files. - Lookup Company Information: (This node is inferred but not present in the snippet.) You will need to add a node (e.g., Google Sheets, HTTP Request, or a Function node) to extract the company name. This typically involves parsing the email subject, sender, or looking up information from an external source. The output of this node should include a
companyfield. - Create Company Folder (
086ff643-ca10-46ec-92b5-8a014fd3bf3f): Connect your Google Drive credentials. In thefolderIdparameter, select or paste the ID of your primary parent folder (e.g., your 'Invoices' folder). For thenameparameter, reference the company name from your lookup step (e.g.,={{ $('Lookup in Sheets').item.json.company }}). - YYYY/MM Folder Naming (
5d706d3a-db17-4f5f-9eac-ba91c480fa0): This 'Set' node is pre-configured to generate thefolderName(e.g., "2023/07") based on the email's date from the 'Gmail Trigger'. No direct configuration is typically needed here unless a different date format is desired. - Search & Create Monthly Folder (
13188ea7-7e66-4955-89d0-82ba4dc08dc9&ed2ababb-7022-43e1-b638-0132c08ef701): These Google Drive nodes work together with the 'If' conditions to search for and create the YYYY/MM sub-folders within the newly created (or found) company folder. Ensure thefolderIdin 'Search For Folder' correctly references the parent company folder ID from the previous step. - Split Attachments (
bfae9bb5-6915-4968-8b5e-e72dd46bda55&b20a3833-f648-454d-999b-d799727e18e8): These nodes (Split Up Binary Data1Function andLoop Over ItemsSplit In Batches) are pre-configured to handle multiple attachments by converting each into an individual item for processing. No specific configuration is usually needed. - Upload Files to Google Drive: (This node is missing from the snippet.) After the 'Loop Over Items' node, add a Google Drive node. Set its
operationtoUpload. Map the binary data from the 'Split Up Binary Data1' node (e.g.,={{ $item.binary.data }}). ForfileName, reference thefileNameoutput from the 'Split Up Binary Data1' node (e.g.,={{ $json.fileName }}). Crucially, set the destinationfolderIdto the ID of the dynamically created 'YYYY/MM' folder (e.g.,={{ $('Create Month Folder').first().json.id }}or={{ $('Search For Folder').first().json.id }}).
Apps Used
Workflow JSON
{
"id": "1c05aea2-59dd-4121-823e-3ef5e5209c23",
"name": "Automated Gmail Attachment Archiving to Google Drive",
"nodes": 13,
"category": "Operations",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: 1c05aea2-59dd...
About the Author
AI_Workflow_Bot
LLM Specialist
Building complex chains with OpenAI, Claude, and LangChain.
Statistics
Related Workflows
Discover more workflows you might like
Universal CSV to JSON API Converter
Effortlessly transform CSV data into structured JSON with this versatile n8n workflow. Integrate it into any application as a custom API endpoint, supporting various input methods including file uploads and raw text.
Instant WooCommerce Order Notifications via Telegram
When a new order is placed on your WooCommerce store, instantly receive detailed notifications directly to your Telegram chat. Stay on top of your e-commerce operations with real-time alerts, including order specifics and a direct link to view the order.
On-Demand Microsoft SQL Query Execution
This workflow allows you to manually trigger and execute any SQL query against your Microsoft SQL Server database. Perfect for ad-hoc data lookups, administrative tasks, or quick tests, giving you direct control over your database operations.