Invoice Data Extraction with Gemini AI and Google Sheets - n8n Workflow

Use this powerful n8n workflow to automatically monitor Google Drive for new PDFs, extract structured invoice data using Google Gemini, and log results directly into Google Sheets. Get started with n8n templates today.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Accountants and bookkeepers needing to streamline invoice data entry.
Businesses processing high volumes of vendor invoices automatically.
Developers looking for advanced n8n templates utilizing modern AI agents.
Users aiming to build robust, serverless pdf_processing pipelines using an n8n node structure.

Overview

Manual invoice data entry is time-consuming and prone to human error. This advanced n8n workflow solves this problem by creating a fully automated pipeline. It continuously monitors a designated Google Drive folder for new PDF files. Upon detection, it utilizes an AI agent powered by Google Gemini (via the LangChain n8n node) to perform intelligent data extraction, specifically looking for structured fields like vendor name, amount, and due date. Furthermore, the n8n workflow incorporates logic using the Compare Datasets n8n node and Google Sheets to prevent duplicate processing, ensuring efficiency and data integrity. This specific n8n workflow template provides a powerful foundation for financial automation.

How it Works

The process is initiated by the Google Drive Trigger n8n node, acting as the primary n8n trigger, which monitors a specific folder for new files.


  1. File Identification and Comparison: The n8n workflow simultaneously fetches the list of new files and reads a list of previously processed file IDs from Google Sheets (Read processed docs1). The Compare Datasets1 n8n node then filters out any invoices already logged, ensuring only new items proceed.

  2. Download and Extraction: For unique files, the Google Drive n8n node downloads the PDF content. The Extract from File1 n8n node converts the PDF binary into raw text data.

  3. AI Processing: The core extraction happens via the AI Agent - get targeted elements from text1 n8n node. This agent leverages the Google Gemini Chat Model and a Structured Output Parser1 to analyze the raw text and output the required invoice fields in a clean JSON format.

  4. Data Structuring: The output is routed through a Code in JavaScript1 n8n node to finalize formatting for spreadsheet insertion.

  5. Logging to Sheets: The Update invoice Fields1 Google Sheets n8n node writes the structured data to the master invoice tracker. A final Google Sheets n8n node (Log the processing of the doc1) marks the file ID as processed, preparing the system for the next run of this comprehensive n8n workflow.

Installation Guide

To deploy this powerful n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON into your n8n instance using the 'Import Workflow' function.

  2. Credentials Setup: Configure the required credentials for each n8n node:

Google Drive/Gmail: Requires OAuth 2.0 credentials for file access, triggering, and email notifications.
Google Sheets: Requires OAuth 2.0 credentials for read/write access to your processing log and main invoice sheet.
* Google Gemini (LangChain Nodes): Requires an active Google Gemini API key.

  1. Trigger Configuration: Activate the Google Drive Trigger1 n8n trigger and ensure it is pointing to the correct input folder for your PDF invoices.

  2. Sheet Setup: Update all Google Sheets n8n node references (Sheet ID, Range) to match your specific tracking spreadsheets.

  3. Activation: Once all credentials and parameters are set, activate the n8n workflow to begin automatic processing.

Node Details

Detailed Breakdown of Key n8n Nodes

Google Drive Trigger1 (n8n Trigger):
Function: Starts the n8n workflow whenever a new file is uploaded to the monitored Google Drive folder.
Key Configuration: Monitors a specific Folder ID for new items.
Read processed docs1 / Update invoice Fields1 / Log the processing of the doc1 (Google Sheets n8n node):
Function: Used extensively for managing state (tracking processed files) and logging the extracted invoice data.
Key Configuration: Reads/Appends data using specified Spreadsheet IDs and Sheet names.
Compare Datasets1 (Core Logic n8n node):
Function: Compares the list of newly detected files against the list of already processed files (from the Google Sheets log) to ensure idempotent execution and prevent duplicates.
Download file1 (Google Drive n8n node):
Function: Fetches the actual binary content of the PDF file identified by the trigger.
Extract from File1 (PDF Processing n8n node):
Function: Converts the binary PDF file into extractable, readable text, preparing it for AI analysis.
AI Agent - get targeted elements from text1 (LangChain Agent n8n node):
Function: The primary intelligence engine. It utilizes the text, the Google Gemini Chat Model2, and the Structured Output Parser1 to intelligently find, validate, and extract structured data elements (like invoice numbers and totals).
Code in JavaScript1 (n8n node):
Function: Performs final transformation and cleanup on the structured AI output before insertion into Google Sheets.

Related n8n Workflows

Paid

Nodes: 14 Nodes
Updated: December 26 2025
View all
Created by

🚀 Business & tech consultant specialized in No Code automation and AI. I help SMEs, startups, and independents save time and cut costs with scalable workflows in n8n and other tools. Passionate about making automation simple, useful, and human-centered. 👉 Also sharing automation insights on YouTube Find all my links here : https://linktr.ee/cashflows.routine And my AI Agency here : https://agence-alain.fr

Featured*