Automatic Invoice PDF Management and Logging to Google Sheets - n8n Workflow

Use this efficient n8n workflow to automatically download Gmail invoice PDFs, upload them to Google Drive, and log key transaction data to Google Sheets. This n8n workflow simplifies financial record-keeping.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Accounting and Finance professionals needing automatic invoice archiving.

  • Small business owners looking to automate expense tracking.

  • Users seeking pre-built n8n templates for email and cloud storage automation.

  • Anyone who receives frequent invoice PDFs via email and needs structured data logging.

Overview

Manually handling incoming invoices is a tedious and error-prone process. This powerful n8n workflow eliminates that burden entirely. Designed as a set-it-and-forget-it automation, this n8n template monitors your Gmail inbox for new invoices, ensures they contain PDF attachments, automatically saves those files securely to Google Drive, and then logs all relevant metadata (filename, Drive link, date, sender) into a structured Google Sheet. By using a series of specific n8n node operations, it guarantees consistency and accuracy in your financial records, freeing up significant administrative time. This comprehensive n8n solution ensures no invoice is missed and every transaction is logged correctly.

How it Works

The process begins with the Gmail Trigger n8n node, which acts as the starting point, polling your inbox every minute for unread emails tagged 'Personal'. This n8n trigger automatically downloads any attachments found. The next step is the 'Has PDF Attachments?' n8n node (Filter), which passes the data to the critical 'If' n8n node. This 'If' node checks for the presence of binary data (attachments) to prevent processing empty emails. If attachments are present, the workflow proceeds to the 'Upload to Google Drive' n8n node. This n8n node uploads the PDF, generating a unique filename or using the original one. Immediately following the upload, the 'Log to Google Sheets' n8n node takes the newly created file metadata (including the Drive link and file ID) and appends a new row to your designated spreadsheet. Finally, to ensure the email is not processed again on the next poll, the 'Mark Email as Read' n8n node uses the original message ID retrieved by the initial n8n trigger to update the email status in Gmail.

Installation Guide

To deploy this useful n8n workflow, follow these setup steps:


  1. Import the n8n template: Copy the provided JSON data and paste it directly into your n8n instance using the 'Import Workflow' function.

  2. Gmail Credentials: Connect your Gmail account to the initial 'Gmail Trigger' n8n node. Ensure the permissions allow for reading emails and managing labels.

  3. Google Drive Credentials: Connect your Google Drive account to the 'Upload to Google Drive' n8n node. You may optionally specify a specific Folder ID instead of the default root directory.

  4. Google Sheets Setup:

Create a target Google Sheet document.
Ensure your sheet has appropriate column headers (e.g., File Name, Drive Link, Sender Email, Subject, Date).
* Connect your Google Sheets account to the 'Log to Google Sheets' n8n node, providing the correct Document ID and Sheet Name.

  1. Final Gmail Setup: The final 'Mark Email as Read' n8n node requires the same Gmail credentials. Verify that the Message ID expression ={{ $('Gmail Trigger').item.json.id }} is correctly referencing the data output from the initial n8n trigger.

  2. Activate: Save and activate the n8n workflow.

Node Details

Gmail Trigger n8n node:
Function: Starts the n8n workflow by detecting new emails.
Key Configuration: Polls every minute; checks for unread emails under the CATEGORYPERSONAL label; downloadAttachments is set to true to pull in the PDF.
If n8n node:
Function: Serves as the primary control flow, ensuring that the n8n workflow only proceeds if a binary attachment has been successfully downloaded.
Key Configuration: Condition checks if the $binary object has a length greater than zero: ={{ $binary && Object.keys($binary).length > 0 }}.
Upload to Google Drive n8n node:
Function: Handles the secure storage of the invoice PDF.
Key Configuration: File Name uses an expression to default to a timestamp if no original filename is provided; the input data field is dynamically set to the first attachment (=attachment0).
Log to Google Sheets n8n node:
Function: Records metadata about the uploaded file for centralized tracking.
Key Configuration: Operation is appendOrUpdate; data mapping is set to pull specific file properties (like name, webViewLink, and various IDs) generated by the previous Drive n8n node output.
Mark Email as Read (Gmail) n8n node:
Function: Marks the source email as processed, preventing re-triggering.
* Key Configuration: Uses the operation: markAsRead and references the unique Message ID from the originating Gmail n8n trigger.

Related n8n Workflows

Free

Nodes: 7 Nodes
Updated: December 26 2025
View all
Created by
Toshiya Minami
Toshiya Minami

Featured*