Every month, your accounting team spends hours processing supplier invoices: opening emails, downloading PDFs, extracting amounts, entering them into your ERP or spreadsheet.
What if this process was fully automated? In this guide, we'll build an "automated financial controller" with n8n that processes your invoices in real-time, 24/7.
What We'll Build
By the end of this tutorial, you'll have an n8n workflow that:
- Monitors an email inbox ([email protected]) in real-time
- Detects invoices in attachments (PDF, images)
- Automatically extracts key data: supplier, net amount, VAT, date, invoice number
- Files and archives invoices in Google Drive or your storage
- Updates a tracking sheet (Google Sheets, Airtable, or your ERP)
- Alerts your team for invoices requiring manual validation
Prerequisites
- • An n8n instance (cloud or self-hosted)
- • A dedicated email account for invoices (Gmail, Outlook, or IMAP)
- • A Google account (for Drive and Sheets) or equivalent
- • Optional: An OpenAI or Claude API key for AI extraction
Need help implementing this workflow?
We can deploy this system for you in less than 2 weeks, adapted to your tools.
Request a quote →Workflow Architecture
Here's the complete workflow diagram:
┌─────────────┐ ┌──────────────┐ ┌─────────────────┐
│ Email │───▶│ Invoice │───▶│ Attachment │
│ (Trigger) │ │ Filtering │ │ Extraction │
└─────────────┘ └──────────────┘ └─────────────────┘
│
▼
┌─────────────┐ ┌──────────────┐ ┌─────────────────┐
│ Slack │◀───│ Data │◀───│ OCR / AI │
│ Alert │ │ Validation │ │ Extraction │
└─────────────┘ └──────────────┘ └─────────────────┘
│
▼
┌──────────────────────┐
│ Storage & Export │
│ (Drive + Sheets) │
└──────────────────────┘
Step 1: Configure the Email Trigger
Start by creating a new workflow in n8n and add an Email Trigger (IMAP) or Gmail Trigger node depending on your provider.
Gmail Configuration
Gmail Trigger node settings:
- Poll Times: Every 5 minutes (or webhook for real-time)
- Filters:
has:attachment filename:pdf - Options: Download Attachments = true
Pro Tip: Create a dedicated email address (invoices@...) and ask your suppliers to send invoices there. This simplifies filtering.
Step 2: Filter Emails Containing Invoices
Not all emails with PDFs are invoices. Add an IF node to filter:
// IF node condition
{{ $json.subject.toLowerCase().includes('invoice')
|| $json.subject.toLowerCase().includes('bill')
|| $json.from.email.includes('accounting')
|| $json.from.email.includes('billing') }}
Step 3: Extract Data with AI
This is the magic part. We'll use AI (GPT-4 or Claude) to extract structured information from the invoice.
Option A: Extraction via OpenAI Vision
If your invoices are images or scanned PDFs, use GPT-4 Vision:
// OpenAI node settings
Model: gpt-4-vision-preview
Message:
"Analyze this invoice and extract the following information as JSON:
- supplier_name
- invoice_number
- invoice_date (format YYYY-MM-DD)
- net_amount
- vat
- total_amount
- currency
Reply ONLY with the JSON, no comments."
Option B: Extraction via Claude (Anthropic)
Claude excels at structured extraction. Use the HTTP Request node:
// HTTP Request to Claude API
POST https://api.anthropic.com/v1/messages
Headers:
x-api-key: YOUR_API_KEY
anthropic-version: 2023-06-01
Body:
{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 1024,
"messages": [{
"role": "user",
"content": [
{"type": "image", "source": {"type": "base64", "data": "{{$binary.data}}"}},
{"type": "text", "text": "Extract data from this invoice as JSON..."}
]
}]
}
Step 4: Validate and Clean Data
AI can sometimes make mistakes. Add a Code node to validate:
// Code node - Validate extracted data
const data = $input.first().json;
// Parse AI JSON
let invoice;
try {
invoice = JSON.parse(data.content);
} catch (e) {
return { error: "Invalid JSON", raw: data.content };
}
// Validation
const isValid =
invoice.total_amount > 0 &&
invoice.invoice_date.match(/\d{4}-\d{2}-\d{2}/) &&
invoice.supplier_name.length > 2;
return {
...invoice,
validation_status: isValid ? "OK" : "REVIEW_NEEDED",
processed_at: new Date().toISOString()
};
Step 5: Archive in Google Drive
Create an organized folder structure by year/month/supplier:
Folder structure:
Invoices/
├── 2026/
│ ├── 01-January/
│ │ ├── Amazon/
│ │ ├── AWS/
│ │ └── ...
│ ├── 02-February/
│ └── ...
└── TO_REVIEW/
Expected Results
Invoice processing time
Continuous processing, even at night
Lost or forgotten invoices
Going Further
This basic workflow can be extended with:
- ERP Integration: Automatic sending to Sage, Odoo, or QuickBooks
- Duplicate Detection: Check if invoice already exists
- Bank Reconciliation: Link with bank transactions
- Automated Reporting: Monthly expense dashboard by supplier
- Approval Workflow: Multi-level validation circuit
Conclusion
With n8n and AI, you can transform supplier invoice management from a manual chore into a fully automated process. The "automated financial controller" never sleeps, doesn't make data entry errors, and alerts you only when necessary.
That's intelligent automation serving SMEs.
Want this workflow for your business?
We deploy custom n8n automations for SMEs. Let's discuss your use case.