Automatic email invoice archiving & data extraction with Gmail, Drive & AI
Automated Invoice Archiving Automatically fetch, store, and extract key information from invoices received via email from your ISP or utility provider (electricity, gas, telecom, water, etc.).The workflow saves the in...
Template notes
Automated Invoice Archiving
Automatically fetch, store, and extract key information from invoices received via email from your ISP or utility provider (electricity, gas, telecom, water, etc.).The workflow saves the invoices to Google Drive (or optionally to your personal FTP/SFTP server) and logs all invoice details into Google Sheets via AI-powered extraction.

Read: [Full setup Guide](https://paoloronco.it/n8n-template-automated-invoice-archiving/)
How it works
1. Scheduled TriggerRuns the workflow at a selected interval (e.g., every hour). You can freely adjust the timing. 2. Gmail – Fetch MessagesReads your Gmail inbox and retrieves only messages coming from your ISP/utility provider’s email address, filtering for messages with PDF attachments. 3. Gmail – Download Invoice Fetches the full email content and downloads the attached invoice (PDF). 4. Google Drive – Upload File Uploads the invoice into a specific Google Drive folder of your choice. 5. (Optional) Upload to FTP/SFTP Sends a copy of the invoice to your personal server via secure FTP/SFTP. 6. AI Extraction Pipeline Extract PDF Text – converts the PDF into text (OCR not required if text-based). AI Agent (OpenRouter) – understands the invoice content and extracts structured fields (invoice number, date, provider name, total amount, tax info, line items, etc.) Code Node – sanitizes and parses the JSON from the AI model. 7. Google Sheets – Append Invoice DataAdds a new row to your Google Sheet with all parsed invoice fields. 8. (Optional) CleanupAutomatically deletes:– the Gmail message– the temporary file in Google Drive(Useful when you only want your FTP or Sheets copy.)
Parameters to configure
| Parameter | Description | Recommended configuration | | --- | --- | --- | | Gmail Credentials | OAuth2 credentials needed to read and delete emails. | Create OAuth credentials on Google Cloud → enable Gmail API → paste Client ID & Secret into n8n → “Connect OAuth2”. | | Sender Email Filter | Email address your provider uses to send invoices. | Example: billing@your-isp.com, invoices@utility.it, ciao@octopusenergy.it | | Google Drive Folder | Destination folder for saving invoices. | Copy the folder ID from the Drive URL and paste it into folderId. | | Google Drive Credentials | OAuth2 connection for file uploads/deletions. | Same Google Cloud project → enable Drive API → OAuth connect in n8n. | | FTP/SFTP Server (optional) | Upload invoices to your private server. | Host / IP · Port · Username · Password or SSH Key · Destination path (e.g. /home/user/invoices/). | | AI Model (OpenRouter) | Large-language model used to parse invoice text. | Example: gpt-4.1, llama-3.1, or any preferred OpenRouter model. | | Google Sheets Document | Destination spreadsheet for structured data. | Create a Sheet → add columns (Vendor, Invoice Number, Date, Amount, Service Type, etc.) → insert documentId & sheet name. | | Sheets Credentials (Service Account) | Used for writing into Google Sheets. | Create Service Account → download JSON → add to n8n → share the Sheet with the Service Account email. | | Trigger Interval | How often the workflow checks for new invoices. | Every hour · every 30 minutes · daily at set ti |