Templates / Archive and index legal PDFs from Gmail with Gemini, Sheets and Google Drive

Archive and index legal PDFs from Gmail with Gemini, Sheets and Google Drive

Ready for 3.0

by Oka Hironobu ✓ · 8 views · created 2026-07-19 · Document Extraction, AI Summarization

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

Nodes used (12)

GmailBasic LLM ChainGoogle Gemini Chat ModelStructured Output ParserGoogle SheetsGoogle DriveSlack

What it does

Quick Overview This workflow monitors Gmail for unread emails with PDF attachments, uses Google Gemini to extract Japan Electronic Books Preservation Act filing metadata, logs a searchable index in Google Sheets, and archives documents into Google Drive folders while notifying Slack when extraction or classification fails. How it works 1. Polls Gmail hourly for unread emails that contain attachments and downloads the attached files. 2. Extracts text from the first PDF attachment. 3. Sends the extracted text to Google Gemini to pull out transaction date, counterparty, amount, and document type, and alerts Slack if the document text cannot be read. 4. Builds an Act-compliant PDF filename from the extracted fields and checks that date, counterparty, and amount are all present. 5. If required metadata is missing, posts a warning to a Slack channel to handle the document manually. 6. If metadata is complete, appends a row to a Google Sheets “Document Index”, marks the Gmail message as read to prevent reprocessing, and uploads the PDF to the matching Google Drive folder (invoice/receipt/contract) or flags it in Slack if unclassified. Setup 1. Connect credentials for Gmail, Google Gemini (PaLM) API, Google Sheets, Google Drive, and Slack. 2. Create (or choose) Google Drive folders for invoices, receipts, and contracts, and select the correct folder IDs in the three Google Drive upload steps. 3. Select the target Google Sheets spreadsheet and the “Document Index” sheet (or create it) where the searchable metadata rows are appended. 4. Pick the Slack channel (for example, accounting) used for extraction failures, missing metadata alerts, and unclassified document notifications.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.