Invoice Data Extraction with OCR, Gemini AI, and Airtable - n8n Workflow

Automate invoice processing using this advanced n8n workflow. It uses a local n8n trigger, OCR (Tesseract/PDF), Gemini AI for detailed data extraction, and reliably saves structured results to Airtable. Download this pre-built n8n templates solution now.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

This n8n workflow is ideal for:

Accounting teams needing automated invoice data entry.
Users running self-hosted n8n instances who process documents locally.
Developers looking for complex examples of AI agent tooling integration within an n8n node sequence.
Anyone seeking pre-built n8n templates for document processing and LLM-powered data structuring.

Overview

This comprehensive n8n workflow provides a robust solution for digitizing and structuring data from incoming invoices. Instead of manual data entry, this automation leverages multiple technologies: a Local File n8n trigger initiates the process upon file detection; specialized n8n nodes handle file reading and preliminary OCR (using Tesseract for images or a PDF extractor for PDFs); finally, the Google Gemini AI Chat Model acts as an intelligent agent, using a specialized Tool (Airtable) to interpret the raw text and extract specific fields like invoice number, total, vendor name, and date.

This setup ensures high reliability and adaptability, handling different file types seamlessly. By using this n8n template, you eliminate repetitive administrative work, ensuring extracted data is standardized (e.g., date formats) before being written directly to your Airtable base. A final notification via Telegram provides real-time updates on successful completion of the n8n workflow execution.

How it Works

This automation is initiated by a specific file system event, making it an excellent example of an event-driven n8n workflow.


  1. Start (n8n Trigger): The n8n workflow begins when the Local File Trigger node detects a new file (JPG, PNG, or PDF invoice) dropped into the monitored folder (/image-output/ocr).

  2. File Reading & Check: The Read File n8n node captures the file content. The Check File Type If n8n node inspects the file extension to determine if it is a PDF or an image file (JPG/PNG).

  3. Preprocessing (OCR): If the file is a PDF, the PDF Page Extract community n8n node extracts the raw text. If it is an image (JPG/PNG), the Tesseract community n8n node performs Optical Character Recognition (OCR) to convert the image data into readable text.

  4. Data Consolidation: The Switch n8n node directs the processed text from either the PDF or Tesseract paths to the Aggregate n8n node, which combines the disparate data streams into a single item containing the OCR text.

  5. AI Data Extraction: The extracted text is passed to the Extract Invoice Data (Gemini) Langchain Agent n8n node. This agent, configured with the Google Gemini Chat Model and the Save to Airtable n8n node as its tool, analyzes the raw invoice text. It identifies and extracts specific required fields (Invoice Number, Total, Vendor Name, etc.), standardizing the data (e.g., formatting the date to 'YYYY-MM-DD').

  6. Database Storage: The Save to Airtable n8n node (acting as the AI Tool) executes the write operation, storing the clean, structured invoice data into the specified Airtable base and table.

  7. Notification: Finally, the Telegram n8n node sends a confirmation message to the user, including the summary of the extracted invoice details and confirming that the n8n workflow completed successfully.

Installation Guide

To utilize this complex n8n template, follow these setup steps:


  1. Import: Copy the provided JSON code and import it directly into your n8n instance.

  2. Local File Trigger Setup: The Local File Trigger n8n node must be pointed to an accessible folder path mounted within your n8n environment. Update the path parameter in this n8n trigger.

  3. Tesseract & PDF Nodes: This n8n workflow uses community nodes: n8n-nodes-tesseractjs and n8n-nodes-pdf-page-extract. Ensure these are installed in your n8n instance.

  4. AI Credentials: Provide your credentials for the Google Gemini Chat Model n8n node.

  5. Airtable Configuration: Update the Save to Airtable n8n node with your specific Base ID, Table Name, and API Token. Ensure your table schema matches the required fields (Invoice Number, Invoice Total, Vendor Name, etc.).

  6. Telegram Configuration (Optional): Update the Telegram n8n node with your Bot credentials and Chat ID for receiving notifications. This is a crucial step if you want to verify the output of this n8n workflow in real-time.

Node Details

This n8n workflow relies on a mix of core, community, and Langchain AI n8n nodes:

Local File Trigger: The initial n8n trigger. It monitors a specified local folder (/image-output/ocr) for new file additions, initiating the automated data flow.
PDF Page Extract (Community n8n node): Function: Extracts raw text content from PDF files. Key Configuration: includeRawText: true.
Tesseract (Community n8n node): Function: Performs OCR on image files (JPG/PNG) to convert visual text into machine-readable text. Key Configuration: Uses SINGLE_COLUMN page segmentation mode.
Switch / If Nodes: Function: These core logic n8n nodes (Check File Type, Switch) manage the flow control, directing files based on their extension (PDF, JPG, PNG) to the appropriate preprocessing n8n node.
Google Gemini Chat Model: Function: Defines the Large Language Model (gemini-2.5-flash-preview-05-20) used by the agent to interpret invoice data.
Extract Invoice Data (Gemini) (Langchain Agent): Function: This central intelligence n8n node uses the Gemini LLM and the Airtable Tool to parse the raw OCR output, extract specific key data points (e.g., date, total, vendor), and ensure structured output.
Save to Airtable (n8n node Tool): Function: Acts as a function callable by the Gemini agent. It receives the structured data extracted by the LLM and writes it to the designated Airtable base, fulfilling the core purpose of this n8n workflow.
Telegram: Function: Provides a final confirmation and structured data summary upon successful execution of the n8n workflow.

Related n8n Workflows

Free

Nodes: 12 Nodes
Updated: December 26 2025
View all
Created by
Vinay
Vinay

Featured*