Log Gmail invoice emails to data tables with Claude Haiku

Go to Workflow
0 views
Built by Invara Invara
Created on August 02, 2026

Description

Quick overview
This workflow runs every morning to find unprocessed invoice-like emails in Gmail, uses Anthropic Claude to extract vendor, total amount, currency, date, and description, then logs each validated invoice into an n8n Data Table and labels the source email to prevent duplicates.

How it works
Runs every day at 06:45 on a schedule.
Searches Gmail for the last 90 days of invoice/receipt emails (German and English keywords) while excluding messages that already have the processed label.
Builds a strict Anthropic Claude prompt from the email metadata and text snippets to request invoice fields as JSON only.
Sends the batch to the Anthropic Messages API and receives a JSON array of extracted invoice entries.
Validates the returned data and drops any entries without a literal positive total amount, a supported currency, and a clean YYYY-MM-DD date.
Inserts each remaining invoice as a new row in an n8n Data Table.
Adds a Gmail label to each processed message so it is not picked up again in future runs.

Setup
Connect your Gmail account credentials for both searching messages and applying labels.
Add an Anthropic API credential for the HTTP request to the Anthropic Messages API.
Create an n8n Data Table with columns for date, vendor, amount, currency, and description, then replace YOUR_TABLE_ID with your table ID.
Create or choose a Gmail label for processed invoices, replace YOUR_LABEL_ID in the labeling step, and ensure the Gmail search query excludes the same label (the -label:Processed part).

Requirements
Gmail account with OAuth credentials
Anthropic API key (Claude Haiku, a few cents per month)
n8n 1.60 or newer (Data Tables)

Customization
Adjust the Gmail search query to match the vendors you actually receive invoices from
Change the schedule if a daily run is too often or not often enough
Add a filter node to exclude private subscriptions that arrive in the same inbox

Additional info
The prompt is deliberately strict: it only accepts amounts that appear literally in the email, always takes the gross total instead of the VAT share, and skips order confirmations and payment reminders that carry no sum. A validation step after the model drops anything without a clean amount and date. Unclear invoices are skipped on purpose rather than guessed, because wrong numbers in bookkeeping cost more time than adding one invoice by hand.

Nodes Used (3)

Code
n8n-nodes-base.code
Gmail
n8n-nodes-base.gmail
HTTP Request
n8n-nodes-base.httpRequest