← All N8N workflows
AI & researchCodeGmail TriggerGoogle DriveIfMerge

Send specific PDF attachments from Gmail to Google Drive using OpenAI

Configured with Gmail Trigger, Google Drive, Open Ai, Read Pdf. Review the connections and setup before adapting this template.

Workflow preview
Files / mediaRead PDFRead PdfTransformConfigureEdit FieldsRoutingIs PDFIfRoutingNot a PDFNo OpRoutingIs matchedIfRoutingThis is a matched PDFNo OpRoutingThis is not a matchedPDFNo OpCodeIterate over emailattachmentsCodeAI & modelsOpenAI matches PDFtextual contentOpen AiTransformMergeMergeFiles / mediaUpload file to folderGoogle DriveTriggerOn email receivedGmail TriggerRoutingIgnore large PDFsNo OpRoutingIs text within tokenlimit?IfRoutingHas attachments?IfRoutingThere are noattachmentsNo Op

Node categories in this workflow

  • Files / media
  • Transform
  • Routing
  • Code
  • AI & models
  • Trigger

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
Read PDFFiles / mediaRead PdfSee node parameters
ConfigureTransformEdit FieldsSee node parameters
Is PDFRoutingIfSee node parameters
Not a PDFRoutingNo OpSee node parameters
Is matchedRoutingIfSee node parameters
This is a matched PDFRoutingNo OpSee node parameters
This is not a matched PDFRoutingNo OpSee node parameters
Iterate over email attachmentsCodeCodeSee node parameters
OpenAI matches PDF textual contentAI & modelsOpen AiSee node parameters
MergeTransformMergeSee node parameters
Upload file to folderFiles / mediaGoogle DriveSee node parameters
On email receivedTriggerGmail TriggerSee node parameters
Ignore large PDFsRoutingNo OpSee node parameters
Is text within token limit?RoutingIfSee node parameters
Has attachments?RoutingIfSee node parameters
There are no attachmentsRoutingNo OpSee node parameters

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

  • gmailOAuth2
  • googleDriveOAuth2Api
  • openAiApi

Workflow notes

Send specific PDF attachments from Gmail to Google Drive using OpenAI

Send specific PDF attachments from Gmail to Google Drive using OpenAI

DISCLAIMER: You may have varying success when using this workflow so be prepared to validate the correctness of OpenAI's results.

This workflow reads PDF textual content and sends the text to OpenAI. Attachments of interest will then be uploaded to a specified Google Drive folder. For example, you may wish to send invoices received from an email to an inbox folder in Google Drive for later processing. This workflow has been designed to easily change the search term to match your needs. See the workflow for more details.

How it works

  1. Triggers off on the On email received node.
  2. Iterates over the attachments in the email.
  3. Uses the OpenAI node to filter out the attachments that do not match the search term set in the Configure node. You could match on various PDF files (i.e. invoice, receipt, or contract).
  4. If the PDF attachment matches the search term, the workflow uses the Google Drive node to upload the PDF attachment to a specific Google Drive folder.

Workflow written by David Sha.

Configuration

Configuration

Match on(required): What should OpenAI's search term be? Examples: invoice, callsheet, receipt, contract, payslip. Google Drive folder to upload matched PDFs(required): Paste the link of the GDrive folder, an example has been provided but will need to change to a folder you own. maxTokenSize(required): The maximum token size for the model you choose. See possible models from OpenAI here. replyTokenSize(required): The reply's maximum token size. Default is 300. This determines how much text the AI will reply with.

Send specific PDF attachments from Gmail to Google Drive using OpenAI

Send specific PDF attachments from Gmail to Google Drive using OpenAI

Purpose and structure

This folder contains the Send specific PDF attachments from Gmail to Google Drive using OpenAI workflow. Its executable nodes use code, gmailTrigger, googleDrive, if, merge, noOp, openAi, readPDF, set. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

On email received

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Code/0298_Code_Readpdf_Send_Triggered.json MIT; preserve source notices.

More in AI & research