FREE N8N TEMPLATE · FINANCE & ADMIN

This n8n workflow takes every attachment from new Gmail messages, reads PDF text, and asks an AI model whether it is an invoice, receipt, contract, identity document or something else. It renames the file in a consistent date, type, party and reference format, saves it to the matching Google Drive folder, and logs it in Google Sheets. Unsure results are marked CHECK and saved to a To sort folder.

DIFFICULTY
Beginner
SET-UP TIME
About 40 minutes
NODES
9
CHECKED AGAINST
n8n 2.41
  • Gmail
  • OpenAI or Anthropic
  • Google Drive
  • Google Sheets

LAST REVIEWED OCTOBER 2026

email-attachments-ai-filing-google-drive.n8n.jsonLOCKED

Get the free workflow

Leave your email to copy the workflow and paste it straight onto your n8n canvas.

FREE · NO CREDENTIALS INCLUDED · CLOUD OR SELF-HOSTED

001 / HOW IT WORKS

Step by step, node by node

  1. 01Watch Gmail for attachments

    The Gmail trigger polls for new messages with attachments and downloads them. Narrow the search query to a label or address so personal email is not processed.

  2. 02Make one item per attachment

    A Code node splits each email into one item per file and drops small inline images such as logos in email signatures. It keeps the sender, subject, date and a short snippet of the email body.

  3. 03Check whether the file is a PDF

    An If node sends PDFs to text extraction. Images, Word files and spreadsheets skip extraction and are classified from their file name and the email details.

  4. 04Read the PDF text

    The Extract from File node pulls the text from each PDF. If a PDF is encrypted or damaged, the node continues without text rather than stopping the run.

  5. 05Classify the document with AI

    The Information Extractor node asks your chat model for the document type, the other party, the document date, any reference number, a short title and a confidence rating, using clear definitions for each type.

  6. 06Build the file name and folder

    A Code node maps the type to a Drive folder ID and builds a name like 2026-09-14 - Invoice - Supplier Name - INV-1042.pdf. Low-confidence results get a CHECK prefix and go to the To sort folder.

  7. 07Save to Google Drive

    The Google Drive node uploads the original file, unchanged, to the chosen folder with the new name. The original email and attachment stay in Gmail.

  8. 08Log the filing

    Google Sheets records when the file was filed, who sent it, the subject, the original and new names, the type, the confidence and a link to the file in Drive.

FILE EMAIL ATTACHMENTS INTO GOOGLE DRIVE WITH AI
@New Email WithAttachments{}One Item perAttachment⑂Is It a PDF?▭Read PDF Text✦Classify Document◆Chat Model{}Build File Nameand Folder▲Save to GoogleDrive▦Log to FilingSheet

THE REAL WORKFLOW YOU IMPORT · NODE NAMES AS THEY APPEAR IN N8N

002 / WHY IT EXISTS

Attachments pile up in inboxes. Invoices sit next to signed contracts, receipts and copies of a new starter's driver licence, all with file names like scan_0042.pdf. When the accountant asks for last quarter's receipts or someone needs a contract, it means searching email and downloading files one by one.

This template is for small offices, practices and bookkeepers who want documents to land in a tidy Drive structure without anyone dragging and dropping. The AI only decides the type and a sensible name; the folders, naming rules and access permissions stay under your control, and low-confidence calls are left for a person to sort.

WHO IT'S FOR

  • →Small business owners who keep receipts and invoices in Google Drive
  • →Office managers handling a shared admin or accounts inbox
  • →Bookkeepers who collect client documents by email
  • →Professional services firms that want contracts filed consistently

003 / WHAT YOU NEED

Tick them off as you go. Nothing is saved; it's just a checklist.

004 / SET IT UP

  1. 01

    Import the workflow JSON into n8n and read the Setup Notes sticky note.

  2. 02

    Connect Gmail and change the trigger's search query to the label or address you want to process, then set a polling interval.

  3. 03

    Create the Drive folders and paste their IDs into the FOLDERS list at the top of the Build File Name and Folder node.

  4. 04

    Restrict sharing on the ID documents folder to the people who need it, and keep it separate from folders shared with your accountant.

  5. 05

    Connect Google Drive and Google Sheets, create a Filing log tab with the listed headers, and paste the sheet ID.

  6. 06

    Add your OpenAI credential to the Chat Model node, or replace it with an Anthropic Chat Model connected to Classify Document.

  7. 07

    Forward a handful of real attachments to the inbox, run the workflow manually and check the names, folders and log before activating.

Get the workflow↑

005 / MAKE IT YOURS

  • +Add more document types, such as payslips, BAS statements or insurance certificates, by extending the schema, the system prompt and the FOLDERS list.
  • +Create year and month subfolders automatically with Google Drive search and create folder nodes before uploading.
  • +Send invoices on to the invoice-to-Xero workflow after filing, so bills are entered and the PDF is already in Drive.
  • +Apply a Gmail label such as Filed to each processed email so your team can see what has been handled.
  • +Post a Slack or email alert when an ID document is filed, so someone can confirm it was expected.

FOR AUSTRALIAN BUSINESSES

Identity documents such as driver licences, passports and Medicare cards are personal information that needs careful handling under the Privacy Act 1988. APP 11 expects reasonable steps to protect it, so give the ID folder restricted sharing and delete copies you no longer need. The workflow only sends PDF text, file names and a short email snippet to the AI model; images, including photographed IDs, are classified from their name alone. Sending document text to an offshore AI API is a cross-border disclosure under APP 8, so review the provider's data terms or self-host n8n in an Australian region. For tax records, the ATO generally expects you to keep them for five years, and a tidy Drive structure makes that easier.

Need it hosted in Australia? →

006 / TOOLS IN THIS WORKFLOW

007 / QUESTIONS

Anything else is quicker to answer on a call. Thirty minutes, free, with the people who would build it.

No. Only PDFs go through text extraction. Images are classified using the file name, email subject and a short snippet of the email body, so the picture itself is never sent to the model. Image files that cannot be identified confidently are marked CHECK for a person.

We set up n8n end to end: hosting in Australia, connecting your systems, testing with real data and handing over documentation.

Book a free call→