AI-Powered PDF Invoice Parsing and Categorization to Google Sheets - n8n Workflow

Use this advanced n8n workflow to automatically monitor Google Drive for new PDF invoices, parse structured data using OpenAI (GPT-4o-mini), categorize expenses, and instantly log results to Google Sheets, eliminating manual data entry.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Small business owners seeking to automate bookkeeping.
Accounting professionals tired of manually keying in invoice data.
Technical users looking for robust n8n templates demonstrating advanced AI capabilities.
Anyone needing reliable PDF data extraction combined with Google Drive and Google Sheets operations within an n8n workflow.

Overview

Manual invoice processing is time-consuming and prone to human error. This specialized n8n workflow provides a robust solution by fully automating the pipeline from document receipt to structured data logging. The value of this n8n automation lies in its ability to automatically monitor a designated Google Drive folder for incoming PDF invoices. Once a new file is detected by the n8n trigger, the workflow utilizes the power of OpenAI's GPT-4o-mini model, configured via the dedicated n8n node, to perform intelligent extraction and categorization. By enforcing a strict JSON schema, this n8n workflow ensures the output is consistently accurate, delivering ready-to-use financial data directly into a Google Sheets ledger. This saves hundreds of hours annually and dramatically improves data integrity.

How it Works

This powerful n8n workflow starts with a specific event and follows a structured path to ensure accurate data processing:


  1. Monitoring Trigger: The process begins with the Invoice Folder Monitor n8n trigger, a Google Drive Trigger node, which constantly watches a specific folder in Google Drive for newly created PDF files.

  2. Document Retrieval: Upon detection, the Download Invoice PDF Google Drive n8n node securely downloads the incoming PDF file into the workflow.

  3. Text Extraction: The PDF Text Extractor n8n node processes the binary PDF file, extracting all raw text content (including OCR if necessary) needed for the AI.

  4. AI Parsing & Structuring: The core logic resides in the Invoice Parser AI Agent n8n node, powered by GPT-4o-mini. This agent receives the raw text and follows a highly specific instruction prompt to identify key financial fields (like invoice number, vendor name, total amount, tax, and individual items). It is explicitly linked to the Structured Output Parser n8n node to guarantee the output is returned in the required JSON format.

  5. Final Logging: Finally, the Insert Invoice Data Google Sheets n8n node takes the perfectly structured JSON output from the AI Agent and appends it as a new, clean row into the designated Google Sheet, completing the automated bookkeeping cycle. This entire flow demonstrates how effectively a complex n8n workflow can handle document processing tasks.

Installation Guide

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


  1. Import the n8n Workflow: Copy the provided JSON data and paste it directly into your n8n instance using the 'New' -> 'Import from JSON' option.

  2. Set up Credentials: You will need to configure three primary credentials:

Google Drive: Set up an OAuth2 credential to allow the Google Drive n8n trigger and subsequent nodes to access your files.
Google Sheets: Set up an OAuth2 credential for the Google Sheets n8n node to write data.
* OpenAI API Key: Configure an API key credential for the OpenAI Chat Model n8n node.

  1. Configure Google Drive Trigger: In the Invoice Folder Monitor n8n trigger, ensure you select the specific folder ID you want to monitor for new PDF invoices.

  2. Prepare Google Sheet: Create a new Google Sheet named 'PDF Invoice Parser - n8n template' (or update the node configuration to match your sheet). Ensure the first row of the sheet contains the following exact column headers: Invoice Number, Invoice Date, Due Date, Vendor Name, Total Amount, Currency, Items, Tax, and Category.

  3. Activate: Once credentials and settings are configured, save and activate the n8n workflow.

Node Details

This n8n workflow utilizes several key nodes to achieve end-to-end automation:

Invoice Folder Monitor (Google Drive Trigger):
Function: Serves as the initial n8n trigger, monitoring a specified Google Drive folder for file creation events.
Key Configuration: Event set to fileCreated; Trigger On set to specificFolder.
Download Invoice PDF (Google Drive n8n node):
Function: Downloads the file detected by the trigger, using the file ID expression ={{ $json.id }}.
Key Configuration: Operation set to download.
PDF Text Extractor (n8n node):
Function: Extracts the textual content from the downloaded PDF binary file, preparing it for AI analysis.
Key Configuration: Operation set to pdf.
OpenAI Chat Model (Langchain n8n node):
Function: Provides the Large Language Model engine.
Key Configuration: Model selection is gpt-4o-mini, ensuring efficiency and capability.
Structured Output Parser (Langchain n8n node):
Function: Enforces a rigid JSON schema, guaranteeing the AI output conforms precisely to the required structure for downstream database logging.
Key Configuration: Defines a JSON template including fields like invoicenumber, vendorname, totalamount, and items.
Invoice Parser AI Agent (Langchain n8n node):
Function: Acts as the orchestrator, taking the extracted text and the prompt/schema to produce the final, structured invoice data.
Key Configuration: Contains a detailed system prompt instructing the AI to extract specific fields and categorize the expense (e.g., 'Utilities', 'Software').
Insert Invoice Data (Google Sheets n8n node):
Function: Appends the structured data generated by the AI agent into the designated Google Sheet ledger.
* Key Configuration: Operation set to append. Data is mapped column-by-column using expressions like ={{ $json.output.total
amount }}.

Related n8n Workflows

Free

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by
Billy Christi
Billy Christi

I'm a professional software engineer and n8n expert with a passion for building scalable, no-code and low-code automation workflows. I specialize in creating seamless integrations between APIs, CRMs, and everyday tools to help businesses save time, reduce manual work, and operate smarter. Whether it's automating marketing pipelines, backend systems, or approval processes, I turn complex logic into simple, powerful workflows with n8n.

Featured*