Project Overview:
- Project: AI Invoice Processing Automation
- Platform: n8n (self-hosted workflow automation)
- AI Model: OpenAI GPT-4o-mini
- Objective: Automatically monitor Gmail for incoming invoices, extract structured data from PDF attachments using AI, log everything to a Google Sheets ledger, and alert the finance team when high-value invoices arrive.
Background:
Accounts payable teams spend countless hours on manual invoice data entry — opening email attachments, reading PDF invoices, copying vendor names, amounts, and due dates into spreadsheets. It’s repetitive, error-prone, and scales poorly as a business grows. This automation replaces that entire workflow: it watches your inbox for PDF attachments, extracts all relevant invoice fields using AI, organizes everything into a structured Google Sheets ledger, and flags high-value invoices for immediate attention.
How It Works:
Gmail Monitoring & PDF Detection:
The workflow automatically polls Gmail for new emails containing PDF attachments. It identifies likely invoices by scanning subject lines, sender domains, and attachment filenames — filtering out marketing materials, reports, and other non-invoice PDFs before processing.
AI-Powered Data Extraction:
Each PDF is converted to text and sent to GPT-4o-mini with a structured extraction prompt. The AI identifies and extracts: vendor/company name, invoice number, issue date, due date, total amount, currency, line items with quantities and unit prices, tax breakdown, and payment terms. The output is returned as structured JSON, ready for direct insertion into any system.
Ledger Logging & Smart Alerts:
- Google Sheets Ledger: Every extracted invoice is automatically appended to a master spreadsheet with all fields formatted and organized by date.
- Duplicate Detection: The system checks invoice numbers against existing records to prevent double-entries.
- High-Value Alerts: Invoices exceeding a configurable threshold (e.g., $5,000) trigger an immediate Slack notification to the finance team with full details.
- Weekly Summary: An automated digest of all processed invoices, totals by vendor, and upcoming due dates.