# Route Matching Gmail PDFs to Drive

Source: https://openflow.run/en/templates/route-matching-gmail-pdfs-to-drive/
Content language: en
Template revision: 4ae2934012d3865e7d296909b9a06728464f1991

Files

Classify PDF attachments from Gmail by their content and upload matching files to Google Drive.

[Use in Open Flow](https://console.openflow.run/flows?importUrl=https%3A%2F%2Fraw.githubusercontent.com%2Foomol-lab%2Fawesome-workflow-templates%2F4ae2934012d3865e7d296909b9a06728464f1991%2Fworkflows%2Froute-matching-gmail-pdfs-to-drive%2Ftemplates%2Froute-matching-gmail-pdfs-to-drive.openflow.json)

*   [Open Flow JSON](https://github.com/oomol-lab/awesome-workflow-templates/blob/4ae2934012d3865e7d296909b9a06728464f1991/workflows/route-matching-gmail-pdfs-to-drive/templates/route-matching-gmail-pdfs-to-drive.openflow.json)
*   [n8n JSON](https://github.com/oomol-lab/awesome-workflow-templates/blob/4ae2934012d3865e7d296909b9a06728464f1991/workflows/route-matching-gmail-pdfs-to-drive/templates/route-matching-gmail-pdfs-to-drive.n8n.json)

![Route Matching Gmail PDFs to Drive workflow in Open Flow](https://openflow.run/template-previews/route-matching-gmail-pdfs-to-drive/light.webp)

Classify PDF attachments from Gmail by their content and upload matching files to Google Drive.

## Setup

Connect Gmail, Encodian, Gemini and Google Drive. Set the destination folder ID in **Choose the next attachment** and the matching term in **Prepare PDF classification**. Configure Gmail file transit and replace the example hostname in **Verify complete attachment** with your transit hostname. Enable persistent State.

## Behavior

The workflow polls Gmail every minute, downloads each PDF attachment, extracts its text layer via Encodian, classifies it with Gemini, and uploads matching original PDFs to Google Drive. Non-PDF attachments are skipped.

In n8n

Import the n8n workflow, connect Gmail, OpenAI and Google Drive, set the matching term and Drive folder ID in **Configure**, and activate the trigger.

Inspiration & credits

Adapted from [Send specific PDF attachments from Gmail to Google Drive using OpenAI](https://github.com/enescingoz/awesome-n8n-templates/blob/827110332c21cbe000ab13f6d292d5adb1f1f8db/Gmail_and_Email_Automation/Send%20specific%20PDF%20attachments%20from%20Gmail%20to%20Google%20Drive%20using%20OpenAI.json) in [enescingoz/awesome-n8n-templates](https://github.com/enescingoz/awesome-n8n-templates).

Source collection notice: © 2024–2026 Enes Cingoz, [CC BY 4.0](https://github.com/enescingoz/awesome-n8n-templates/blob/827110332c21cbe000ab13f6d292d5adb1f1f8db/LICENSE). The source credits [David Sha](https://davidsha.me/). See [repository licensing](https://github.com/oomol-lab/awesome-workflow-templates/blob/4ae2934012d3865e7d296909b9a06728464f1991/README.md#licensing) for the scope of OOMOL contributions and third-party material.

## Apps used

*   [**Encodian**`encodian`](https://openflow.run/en/integrations/encodian/)
*   [**Gemini**`gemini`](https://openflow.run/en/integrations/gemini/)
*   [**Gmail**`gmail`](https://openflow.run/en/integrations/gmail/)
*   [**Google Drive**`googledrive`](https://openflow.run/en/integrations/googledrive/)

## What you’ll need

*   Gmail connection and file transit
*   Encodian PDF text extraction
*   Gemini and Google Drive connections
*   Persistent State

*   gmail
*   google drive
*   pdf
*   ai

[View on GitHub](https://github.com/oomol-lab/awesome-workflow-templates/blob/4ae2934012d3865e7d296909b9a06728464f1991/workflows/route-matching-gmail-pdfs-to-drive/README.md)
