Extract & Organize Email Invoices with Gmail, Drive & OpenAI GPT
Who’s it for
This template is for founders, finance teams, and solo operators who receive lots of invoices by email and want them captured automatically in a single, searchable source of truth. If you’re tired of hunting through your inbox for invoice PDFs or “that one receipt from three months ago,” this is for you.
What it does / How it works
The workflow polls your Gmail inbox on a schedule and fetches new messages including their attachments. A JavaScript Code node restructures all attachments, and a PDF extraction node reads any attached PDFs.
An AI “Invoice Recognition Agent” then analyzes the email body and attachments to decide whether the email actually contains an invoice. If not, the workflow stops.
If it is an invoice, a second AI “Invoice Data Extractor” pulls structured fields such as date_email, date_invoice, invoice_nr, description, provider, net_amount, vat, gross_amount, label (saas/hardware/other), and currency. Depending on whether the invoice is in an attachment or directly in the email text, the workflow either:
uploads the invoice file to Google Drive, or
document a direct link to the mail,
then appends/updates a row in Google Sheets with all invoice parameters plus a Drive link, and finally marks the Gmail message as read.
How to set up
Add and authenticate:
Gmail credentials
Google Sheets credentials
Google Drive credentials
OpenAI (or compatible) credentials for the AI nodes
Create or select a Google Sheet with the expected columns (date_email, date_invoice, invoice_nr, description, provider, net_amount, vat, gross_amount, label, currency, link).
Create or select a Google Drive folder where invoices/docs should be stored.
Adjust the Gmail Trigger filters (labels, search query, polling interval) to match the mailbox you want to process.
Update node credentials and resource IDs (Sheet, Drive folder) via the node UIs, not hardcoded in HTTP nodes.
Requirements
n8n instance (cloud or self-hosted)
Gmail account with OAuth2 setup
Google Drive and Google Sheets access
OpenAI (or compatible) API key configured in n8n
Sufficient permissions to read emails, read/write Drive files, and edit the target Sheet
How to customize the workflow
Change invoice categories**: Extend the label enum (e.g., add “services”, “subscriptions”) in the extraction schema and adjust any downstream logic. Refine invoice detection**: Tweak the AI prompts to be more or less strict about what counts as an invoice or receipt. Add notifications**: After updating the Sheet, send a Slack/Teams message or email summary for high-value invoices. Filter by sender or subject**: Narrow the Gmail Trigger to specific vendors, labels, or keywords. Extend the data model**: Add fields (e.g., cost center, project code) to the extractor prompt and Sheet mapping to fit your bookkeeping setup.
Related Templates
Instagram Full Profile Scraper with Apify and Google Sheets
📸 Instagram Full Profile Scraper with Apify and Google Sheets This n8n workflow automates the process of scraping ful...
Auto-classify Gmail emails with AI and apply labels for inbox organization
Who is this for? Professionals and individuals who receive high volumes of emails, those who want to automatically organ...
Compare Lists and Identify Common Items & Differences Using Custom Keys
This workflow compares two lists of objects (List A and List B) using a user-specified key (e.g. email, id, domain) and ...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments