AI-Powered Invoice Data Extraction and Spreadsheet Logging - n8n Workflow

Automate invoice data extraction using this n8n workflow. Triggered by Google Drive, it uses Mistral AI and OpenAI to structure data and accurately log key fields to Google Sheets.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Finance and Accounting Teams: Users who need to automate the capture and processing of incoming vendor invoices or receipts.
Small Business Owners: Those looking to minimize manual data entry for bookkeeping.
Automation Specialists: Developers seeking advanced examples of an n8n workflow integrating OCR, proprietary AI (Mistral), and large language models (OpenAI).
Users of n8n templates: Individuals looking for robust, production-ready solutions for document processing.

Overview

Manual entry of invoice details into a spreadsheet is tedious, slow, and error-prone. This specialized n8n workflow completely automates the process, turning unstructured PDF or image files into clean, structured spreadsheet data.

The n8n trigger watches a designated Google Drive folder. Once a file is uploaded, the automation pipeline takes over, using a Mistral AI n8n node for robust text extraction (OCR). This text is then passed to an intelligent AI Agent powered by OpenAI, which is instructed to act as an invoice analyst. The n8n node then ensures the output conforms to a strict JSON structure before the final details are logged. This powerful n8n solution ensures high accuracy and saves significant administrative time, demonstrating a practical application of AI within a core business process.

How it Works

This fully automated n8n workflow follows a six-step process, initiated instantly upon file upload:


  1. Trigger on Upload (Google Drive Trigger): The n8n workflow starts when a new file (invoice or receipt) is uploaded to a monitored 'Invoices' folder on Google Drive. This acts as the primary n8n trigger.

  2. File Download (HTTP Request): The file details received by the n8n trigger are used to construct an authenticated HTTP request to download the actual media content of the newly created file.

  3. Text Extraction (Extract text - Mistral AI): The downloaded file (likely a PDF or image) is processed by the Mistral AI n8n node. This node performs the Optical Character Recognition (OCR), converting the visual data into machine-readable text (Markdown format).

  4. AI Analysis (AI Agent with OpenAI): The extracted text is fed into the Langchain 'AI Agent' n8n node. This node uses a powerful system prompt ('expert in analyzing invoices') and utilizes the OpenAI Chat Model to interpret the text and identify key data points like dates, addresses, and amounts.

  5. Data Structuring (Structured Output Parser): The AI Agent's response is passed through a dedicated Langchain 'Structured Output Parser' n8n node, which enforces adherence to a predefined JSON schema (e.g., fields for 'invoiceNumber', 'From', 'To', 'dueDate'). This guarantees clean and predictable output for the final step.

  6. Data Logging (Append row in sheet - Google Sheets): Finally, the extracted and structured fields are mapped directly to a designated Google Sheets spreadsheet. This n8n node appends a new row containing the invoice number, relevant dates, recipient/sender details, and the direct link to the original file provided by the initial n8n trigger.

Installation Guide

To utilize this advanced n8n workflow template, follow these steps:


  1. Import: Copy the provided n8n workflow JSON and paste it into your n8n instance.

  2. Credentials Setup: You must configure credentials for the following services:

Google Drive: Set up credentials for both the Google Drive Trigger and the HTTP Request n8n node to allow file watching and downloading.
Mistral AI: Configure the API key for the 'Extract text' n8n node (Mistral Cloud account).
OpenAI: Set up the API key for the 'OpenAI Chat Model' n8n node.
Google Sheets: Provide credentials for the final Append row in sheet n8n node.

  1. Google Drive Configuration: In the Google Drive Trigger n8n node, select the exact folder where you will be uploading your invoices.

  2. Google Sheets Configuration: In the Append row in sheet n8n node, specify the ID and Sheet Name of your target spreadsheet where the extracted data will be logged. Ensure the header names match the fields defined in the workflow (e.g., 'Invoice Number', 'Due Date').

  3. Activate: Save and activate the n8n workflow to begin automation.

Node Details

The following n8n node components drive this data extraction automation:

Google Drive Trigger:
Function: Serves as the starting n8n trigger, polling a specified folder for newly created files.
Key Configuration: Event set to fileCreated, Trigger On set to specificFolder.
HTTP Request:
Function: Downloads the raw file data from Google Drive using the file ID provided by the n8n trigger.
Key Configuration: URL dynamically constructed using the file ID (/files/{{ $json.id }}?alt=media), Response Format set to file.
Extract text (Mistral AI):
Function: Performs OCR on the attached file content, extracting all text into a structured format.
Key Configuration: Uses the Mistral Cloud API credentials.
AI Agent (Langchain):
Function: Orchestrates the AI process, using a predefined expert persona to analyze the extracted invoice text.
Key Configuration: Prompt defined as You are an expert in analyzing invoices. Here is an invoice... using the input Markdown text.
OpenAI Chat Model (Langchain):
Function: The core Large Language Model (LLM) processing the request, serving the AI Agent.
Key Configuration: Model set to gpt-4.1-mini.
Structured Output Parser (Langchain):
Function: Ensures the data generated by the LLM is transformed into a reliable, consistent JSON structure.
Key Configuration: Defined JSON Schema example for required fields like invoiceNumber, From, dueDate, etc.
Append row in sheet (Google Sheets):
Function: The final action n8n node, logging the parsed, structured data into a spreadsheet.
* Key Configuration: Operation set to append, mapping data fields (e.g., invoiceNumber and webViewLink from the original n8n trigger data) to specific sheet columns.

Related n8n Workflows

Free

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by
Aemal Sayer
Aemal Sayer

Featured*