Mindket

Gmail PDF attachments matched by AI and saved to Drive

Newversion 1 · updated

Overview

An n8n workflow that has OpenAI check each PDF attached to new Gmail against a document type you set and uploads matches to Drive.

Gmail PDF attachments matched by AI and saved to Drive is an n8n workflow in the Productivity category, listed by Mindket. It is free. This is version 1, last updated on . Download it on this page or copy its JSON, then import it into an n8n canvas. Nothing runs until you activate it in n8n.

At a glance

Runs in
  • n8n Cloud: import the file there and activate it
  • Your own n8n server: the same file and steps
  • Gmail: the mail with the attachments
  • Google Drive: the folder that receives the matches

Platform

Connects 3 apps

How it works

Trigger

New Gmail message

It starts when Gmail, checked every minute, shows a new message with attachments:

  • The kind of document to keep, set in Configure as Match on
  • The Drive folder link, set in Configure
  • The token limits for the PDF text and the answer, set in Configure

Actions

  1. Each attachment becomes its own item, and only files with the extension pdf go on
  2. The text of the PDF is read, and a PDF whose text is too long is ignored
  3. OpenAI answers true or false for whether the PDF looks like the kind of document you named
  4. The answer is merged with the PDF, and only a true goes on
  5. The matching PDF is uploaded to the Google Drive folder

Result

Matching PDFs saved in a Google Drive folder

Integrations

What you need before you start.

Gmail

Mailbox

Supplies new messages with their attachments.

NeedsA Gmail credential

OpenAI

Language model

Judges from the file name and text whether a PDF matches the document type.

NeedsAn OpenAI API key

Google Drive

File storage

Receives each matching PDF in the folder you set.

NeedsA Google Drive credential and a folder

Workflow check

Checked by Mindket on 13 Nov 2026

Steps
17 steps, starting on a Gmail event
AI
No step calls an AI model
Sign-ins
Signs in to: OpenAI, Google Drive and Gmail
API keys
No API key is left in the file
Step types
Mindket’s checker reads all 9 of its step types

Read from the workflow’s file, not from a run.

About

What it is

This n8n workflow watches Gmail for mail with PDF attachments. It reads the text of each PDF and asks OpenAI whether the file looks like the kind of document you named, such as an invoice, receipt, contract or payslip. Matching PDFs go to a Google Drive folder. Seventeen nodes run it, beside two sticky notes.

Who it suits

People who receive documents by email and want the right ones filed in a Drive folder for later work. Skip it if you need a guaranteed result, because the model can be wrong, or if the PDFs cannot go to OpenAI.

Who uses it, and how
IndustryWho uses itHow they use itExample
AccountingBookkeepersFile invoices that arrive by emailA bookkeeper’s inbox sends each supplier invoice to an intake folder.
HRPayroll teamsCollect payslipsA payroll clerk gathers the payslips a provider emails each month.
LegalParalegalsPull contracts out of mixed mailA paralegal finds signed contracts in one folder.
FreelanceFreelancersKeep receipts togetherA freelancer saves every receipt for the tax return.

You need some n8n and a Google account: import a file, add three credentials, name a document type and paste a folder link.

Where to use it

Any n8n that can reach Gmail, OpenAI and Google Drive will run it. The files appear in the Drive folder you choose.

  • n8n Cloud: import the file there and activate it
  • Your own n8n server: the same file and steps
  • Gmail: the mail with the attachments
  • Google Drive: the folder that receives the matches

Setup

Download saves a zip with workflow.json and Mindket’s setup notes in your downloads folder. Setup takes three credentials, a document type and a folder link.

What you need first
NeedDetail
n8nOn n8n Cloud or on a server of your own
GmailA Google account for the mailbox
OpenAIAn API key
Google DriveA folder you own, and its link
  1. In n8n, create a workflow, open its menu, choose Import from File and pick workflow.json.
  2. Add credentials for Gmail, OpenAI and Google Drive, and select them in the nodes that ask for one.
  3. In Configure, set Match on to the kind of document to keep.
  4. In the folder link, replace <YOUR_FOLDER_ID> with your folder’s id.
  5. Activate the workflow and send yourself a mail with a PDF.

How to use it

Activate the workflow. Gmail is checked every minute, and each PDF in a new message is read and judged. A match appears in the Drive folder a little later. Check the folder now and then.

What to change for a different result
To changeWhere
What to look forMatch on in Configure
The folderThe link in Configure
The size limit and the answer lengthmaxTokenSize and replyTokenSize
The model and the questionThe body of OpenAI matches PDF textual content

Example

A bookkeeper sets Match on to invoice. A supplier writes with an invoice and a brochure attached.

Both are PDFs and both are read. OpenAI answers true for the invoice and false for the brochure, so only the invoice is uploaded to the folder.

For newcomers and experts

If you are new. n8n draws a workflow as boxes joined by lines, and each box, a node, does one job. Here one box splits the attachments, one reads a PDF, one asks the model and one uploads the file. Try it with one invoice first.

For experts. A Code node turns each attachment into its own item. A chat request answers true or false per PDF, and a Merge node puts that answer back beside the file so the upload still has its binary data.

Where to look closer
NodeWhat it doesWhat to know
Is text within token limit?Skips PDFs whose text is too longIt divides the length by four to estimate tokens
OpenAI matches PDF textual contentAsks Chat Completions for true or falseThe reasoning effort is none, so a short answer limit is enough
Match ResultTrims and lowercases the answerIs matched accepts only the word true
Upload file to folderSaves the PDF to DriveIt takes the folder id from the end of the link

Good to know

Each PDF costs one OpenAI call, and a wrong answer can file the wrong document or skip the right one.

  • The repair: n8n’s older OpenAI text node used its default model, gpt-3.5-turbo-instruct. OpenAI’s deprecations page, read on 12 November 2026, lists it as shut down on 28 September 2026. This copy calls Chat Completions with gpt-6-luna
  • Temperature: the old setting of 0.1 is gone, since the model page lists no temperature
  • Limits: maxTokenSize is 4000, a cautious number, and the model page lists a context of 1,050,000 tokens
  • The folder link: leave off anything after the id, such as a sharing suffix
  • Not run: this copy was not run against Gmail, OpenAI or Google Drive
  • Your data: each PDF’s name and text go to OpenAI, and matched files go to Drive
  • Credentials: the JSON holds none

README and files

README

Gmail PDF attachments matched by AI and saved to Drive

An n8n workflow that watches Gmail for new mail with PDF attachments. It reads the text of each PDF and asks OpenAI whether the file looks like the kind of document you named, such as an invoice, receipt, contract or payslip. Matching PDFs go to a Google Drive folder.

What is inside

  • workflow.json: the workflow as n8n exports it, nineteen nodes: seventeen that do the work and two sticky notes. It holds no credential.
  • README.md: these notes.

What we changed from the original copy

  • The credential links are gone. Select your own for Gmail, OpenAI and Google Drive.
  • OpenAI matches PDF textual content was n8n's older OpenAI text node. The file names no model, so the node used its default, gpt-3.5-turbo-instruct. OpenAI's deprecations page, read on 12 November 2026, lists that model as shut down on 28 September 2026 with gpt-5.6-terra as the replacement. The model page for gpt-5.6-terra shows the legacy Completions endpoint as not supported.
  • The node is now an HTTP Request to Chat Completions. It names gpt-6-luna, sets reasoning_effort to none and takes max_completion_tokens from replyTokenSize. The temperature of 0.1 is gone, because the model page lists no temperature setting.
  • A new Match Result node follows it. It trims the answer and lowercases it into text, which Merge and Is matched read.
  • The Drive folder link belonged to the author. It is https://drive.google.com/drive/folders/<YOUR_FOLDER_ID> now.
  • The notes are rewritten. One of them carried its author's name and a site link. A comment with a forum link at the top of the attachment splitter is removed.
  • Nothing else.

Before you start

  • An n8n instance, on n8n Cloud or your own server.
  • A Gmail account and an OpenAI API key.
  • A Google Drive folder you own, and its link in the form https://drive.google.com/drive/folders/<id>.

Set it up

  1. In n8n, create a workflow, open its menu and choose Import from File. Pick workflow.json.
  2. Add a Gmail credential and select it in On email received.
  3. Add an OpenAI credential and select it in OpenAI matches PDF textual content.
  4. Add a Google Drive credential and select it in Upload file to folder.
  5. In Configure, set Match on to the kind of document to keep, and replace <YOUR_FOLDER_ID> in the folder link with your folder's id. Leave off anything after the id, such as ?usp=sharing.
  6. Save and activate the workflow, then send yourself a mail with a PDF.

How a run goes

  1. On email received polls Gmail every minute and downloads attachments, named with the prefix attachment_.
  2. Configure holds the settings. Has attachments? stops mail without a file.
  3. Iterate over email attachments makes one item per attachment, and Is PDF keeps the files with the extension pdf.
  4. Read PDF extracts the text. Is text within token limit? compares the text length divided by four with maxTokenSize minus replyTokenSize, and Ignore large PDFs takes the longer ones.
  5. OpenAI matches PDF textual content gets the file name and the text and answers true or false. Match Result cleans the answer up.
  6. Merge combines the answer with the PDF, and Is matched passes only a true. Upload file to folder saves the file to the folder named by the link's last part.

Change the look

  • What to look for: Match on in Configure.
  • The folder: the link in Configure.
  • The size limit and the answer length: maxTokenSize and replyTokenSize.
  • The model and the question: the body of OpenAI matches PDF textual content.
  • How often Gmail is checked: On email received.

Good to know

  • The model can be wrong, so check the folder now and then.
  • A PDF matches only when the cleaned answer is exactly true.
  • Each PDF costs one OpenAI call. maxTokenSize is 4000, a cautious number, and the model page for gpt-6-luna lists a context of 1,050,000 tokens, so long PDFs can be allowed by raising it.
  • This copy was not run against Gmail, OpenAI or Google Drive.
  • Each PDF's name and text go to OpenAI, and matched files go to Drive.
  • The JSON holds no credential.
Files
NOTICE.md  687 B
README.md  4 KB
workflow.json  12 KB

3 files, 17 KB, downloaded as a zip.

What’s new

  • Version 1 · 2026-11-12

Reviews

No ratings yet

Write a review

No reviews yet.

More from Mindket

See all from Mindket

anaksor-ocr

Sokheng · Kit

Reads Khmer and English text from documents, receipts and photos of signs, using a detector for text lines and a recogniser for each line. Suits developers who…

New

Qwen2.5-7B-Instruct as GGUF files in eight quantization sizes, to chat with locally through llama.cpp. For people who want a capable 7.6B model on their own co…

New

ACE-Step 1.5 XL SFT

ACE-Step · Kit

Generates music from text with a 4B diffusion decoder, 50 steps and guidance control, aiming for higher audio quality than the base. For creators with a GPU of…

New

Similar in Productivity

See all in Productivity

Guizang PPT Skill

op7418 · Skill

Skill that makes single-file HTML slide decks, slide illustrations and platform covers in two visual styles, with a presenter mode for rehearsal. For speakers…

New29.8k

Frontend Slides

zarazhangrui · Skill

Builds HTML presentations from scratch or from a PowerPoint file and shows visual style previews to pick from, for people who want web slides with no CSS or Ja…

New32.3k

IPTV

iptv-org · Kit

Collects publicly available live TV channels from many countries into playlists that any video player with live streaming can open. Made for viewers and for de…

New144k