AI Document Extraction and Dynamic Google Sheets Storage - n8n Workflow

Automate document processing using this advanced n8n workflow. It classifies documents via Gemini, extracts structured data with VLM Run, and dynamically maps fields to Google Sheets using an n8n AI Agent.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Businesses requiring automated expense reporting or invoice processing.
HR professionals needing automated resume intake and parsing.
Developers or engineers looking for complex, integrated n8n templates.
Anyone needing an advanced n8n workflow for high-volume, variable document handling.

Overview

This sophisticated n8n workflow addresses the complex challenge of processing heterogeneous documents (like receipts, resumes, or blueprints) and achieving highly structured, categorized data storage without manual intervention. The core value of this n8n automation lies in its dynamic routing capability. When a document lands in Google Drive, the n8n workflow uses the Google Gemini n8n node to classify the document type. This classification then informs the VLM Run extraction step, which performs high-precision OCR and layout parsing to convert the document into structured JSON data. Finally, an intelligent n8n AI Agent node takes over the logic flow. This agent uses its tools to search a master index sheet and determine the correct target Google Sheet for storage. The agent handles conditional logic, ensuring correct header creation and meticulous field mapping based on the document type, making this one of the most powerful n8n templates available for unstructured data processing.

How it Works

This n8n workflow operates in a multi-stage, event-driven pattern:


  1. Trigger and Download: The n8n trigger, a Google Drive Trigger n8n node, monitors a designated folder for new file uploads. Upon detection, the file is downloaded twice (once for classification and once for detailed extraction).

  2. AI Classification: The Check Document Type n8n node, utilizing Google Gemini, analyzes the binary document to determine its category (e.g., 'Resume', 'Receipt').

  3. Structured Extraction: The VLM Run for Extraction n8n node receives the classified type and the document. It executes a powerful VLM agent to perform deep extraction, creating a clean JSON output schema.

  4. Callback and Agent Activation: The extracted JSON data is sent back to the n8n workflow via the Receives Extracted Data Webhook n8n node.

  5. Dynamic Storage Logic: The AI Agent for Storing Dynamically n8n node takes the extracted JSON. This agent's complex system prompt directs it to use its Google Sheets tools (Get row(s), Append row HTTP Request n8n node) to:

a. Search a master index sheet for the matching document type and retrieve the target Spreadsheet ID.
b. Use the Get row(s) tool to check if the target spreadsheet has existing header columns.
c. If headers are missing, the agent uses the Append row HTTP Request n8n node to create them using the pre-defined JSON keys (e.g., Name, Email).
d. Finally, it uses the Append row n8n node again to append the extracted values, ensuring they align perfectly with the dynamic header structure. This intelligent automation makes the n8n workflow extremely flexible.

Installation Guide

To deploy and utilize this powerful n8n workflow, follow these setup steps:


  1. Import: Download the JSON and import it into your n8n instance via the 'Import from JSON' feature.

  2. API Credentials: You must configure credentials for every service used in this n8n template:

Google Drive OAuth2 (for the n8n trigger and download nodes).
Google Gemini (PaLM) API (for document classification).
VLM Run API (for high-precision extraction).
OpenAI API (for the internal LLM engine powering the AI Agent n8n node).
* Google Sheets OAuth2 (for dynamic read/write operations).

  1. Google Drive Trigger Setup: Configure the Monitor Uploads n8n trigger node to point to the specific Google Drive folder ID you wish to monitor for new documents.

  2. Agent Index Configuration: Open the AI Agent for Storing Dynamically n8n node. Update the fixed spreadsheet ID in the system message (1-e3vUMWxJ8Gqj7Ifp7hlESl726tnHaqqFf9DYc1kE) to the ID of your custom master index sheet, which maps document types to their respective target sheet IDs. This spreadsheet is crucial for the n8n workflow's routing.

Node Details

Monitor Uploads (Google Drive Trigger n8n node): The primary n8n trigger. It listens for the fileCreated event in a specific folder, initiating the entire n8n workflow.
Check Document Type (Google Gemini n8n node): Crucial for routing. This n8n node analyzes the file's binary data to provide an accurate document classification (e.g., Resume, Claims Processing).
VLM Run for Extraction (VLM Run n8n node): Performs complex layout parsing and OCR based on the document type, resulting in highly structured JSON. It sends its output to a Webhook n8n node.
Receives Extracted Data (Webhook n8n node): Acts as the asynchronous callback endpoint, receiving the structured JSON data once VLM Run completes its task.
AI Agent for Storing Dynamically (Agent n8n node): The orchestration engine. This n8n node uses OpenAI's LLM to execute conditional logic against its configured tools (Get row(s) and Append row). Its sophisticated prompt defines the mapping schema for documents like Receipts, Resumes, and Blueprints, ensuring the n8n workflow maintains data integrity.
Get row(s) from sheets & Append row (Google Sheets Tools): These n8n nodes are exposed as tools to the AI Agent, allowing it to dynamically verify headers, retrieve sheet IDs from the index, and write the final, mapped data to the correct Google Sheet.

Related n8n Workflows

Free

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

AI and Automation engineer with 2 years of experience helping businesses streamline workflows using tools like n8n, Make, and Zapier. I also build custom Python solutions and AI integrations tailored to your needs. Use my link to book an initial consultation for automation and AI projects.

Featured*