Automated Invoice Filing and AI Data Extraction using Google Drive and Sheets - n8n Workflow

Leverage this n8n workflow to fully automate invoice processing. Monitor Google Drive for new PDFs, use AI to extract data, file documents by year/month, and log financials in Google Sheets.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Accountants and Bookkeepers: Professionals needing to streamline high-volume document handling and data entry.
Small Business Owners: Users looking for a hands-free method to organize financial records.
n8n Automation Specialists: Individuals seeking advanced examples of integrating AI models (LangChain/OpenAI) with file system operations.
Users of n8n templates: Anyone looking for a complete, production-ready solution for document processing.

Overview

Handling invoices is a repetitive, error-prone task. This comprehensive n8n workflow solves this by providing a complete, end-to-end automation solution. The automation begins the moment a new invoice PDF is uploaded to a designated Google Drive inbox folder. Using a powerful combination of PDF parsing and AI (specifically the LangChain Information Extractor n8n node, backed by an OpenAI model), the workflow intelligently extracts critical fields like invoice number, customer name, net amount, and dates. This extracted data is then used to perform two crucial actions: first, it automatically moves the original PDF file into the correct, corresponding year and month folder structure in Google Drive, and renames the file for easy identification. Second, it logs all extracted structured financial data into a Google Sheets overview. This robust n8n workflow acts as a centralized digital filing cabinet and data entry system, ensuring zero manual input and maximizing efficiency. This is a powerful n8n template for finance automation.

How it Works

This automation starts with the dedicated n8n trigger, the Google Drive Trigger.


  1. Trigger and Ingestion: The Google Drive Trigger monitors a specific 'Invoices-Inbox' folder for newly uploaded PDF files. When a file is detected, the workflow activates. The subsequent Split in Batches n8n node ensures that if multiple files are dropped simultaneously, they are processed individually.

  2. File Processing: The workflow uses the Google Drive n8n node to download the new file and then passes it to the Extract From File n8n node, which extracts the raw text content from the PDF.

  3. AI Data Extraction: The extracted raw text is sent to the Information Extractor n8n node (integrated with the OpenAI Chat Model). This AI component utilizes a detailed system prompt and a required attribute schema to parse the German-formatted text and output structured JSON data containing all necessary invoice details (date, amount, customer, year, month, etc.).

  4. Intelligent Filing: Using the newly extracted 'Year' and 'Month' variables, the workflow uses Google Drive n8n nodes (GetYearFolder, GetMonthFolder) to locate the correct target subdirectory within the accounting archive.

  5. Reorganization and Renaming: The original invoice file is then moved (MoveFile) into the identified monthly folder. A final Google Drive n8n node (UpdateFileName) renames the file according to a standardized schema (e.g., Customer Month Year).

  6. Documentation: The final step uses the Google Sheets n8n node (AddToOverview) to append all the structured data extracted by the AI into a centralized financial log, completing the n8n workflow's documentation task. There is also an auxiliary portion of this n8n template that creates the required year and month folders automatically if they do not exist.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import: Copy the provided JSON data and import it directly into your n8n instance as a new n8n workflow.

  2. Google Drive Setup: You need a Google Drive credential configured in n8n. Ensure this credential has access to the Invoice Inbox folder and the main Accounting Archive where the files will be sorted. Configure the Google Drive Trigger and Search files and folders n8n node to monitor your chosen input directory.

  3. OpenAI/LangChain Setup: You need an OpenAI/Gemini credential linked to the OpenAI Chat Model n8n node. This n8n node is crucial for the AI extraction process. Ensure your API key is configured correctly.

  4. Google Sheets Setup: Configure a Google Sheets credential. In the AddToOverview n8n node, select your target spreadsheet and ensure the column headers in the node's configuration match the headers in your physical Google Sheet (e.g., Kundennummer, Kunde, Nettobetrag, etc.).

  5. Activate: Once credentials and folder IDs are updated across all relevant n8n nodes, save and activate the n8n workflow.

Node Details

This n8n workflow relies on a mixture of core n8n nodes and specialized AI integrations:

Google Drive Trigger: The starting n8n trigger. It monitors a specific Google Drive folder (Rechnungsablage) for the fileCreated event, initiating the entire process.
Loop (Split in Batches): Ensures high reliability by processing each incoming file from the Google Drive n8n trigger individually.
Google Drive (GetFile): Downloads the actual binary PDF file content from Google Drive using the file ID provided by the n8n trigger output.
Extract From File (PDF): A crucial n8n node that converts the downloaded PDF content into raw text, preparing it for AI processing.
OpenAI Chat Model / Information Extractor (LangChain): These two LangChain n8n nodes form the core intelligence. The Information Extractor uses a sophisticated prompt structure to reliably pull defined attributes (e.g., Rechnungsnummer, Nettobetrag, Monat) from the raw invoice text. It requires an active connection to the OpenAI Chat Model n8n node.
Google Drive (Folder Operations): Multiple instances of this n8n node (GetYearFolder, GetMonthFolder, MoveFile) handle the file organization logic, using data extracted by the AI to dynamically find the correct filing location.
Google Drive (UpdateFileName): Renames the processed file using an expressive combination of extracted data (Customer Name, Month, Year).
Google Sheets (AddToOverview): The final n8n node in the processing path. It appends the complete, structured invoice data set (extracted by the AI) into the designated spreadsheet row.

Related n8n Workflows

Free

Nodes: 11 Nodes
Updated: December 26 2025
View all
Created by
Romain
Romain

Featured*