Log email receipts to Google Sheets with Gmail and OpenAI

Go to Workflow
9 views
Built by 43 Sunsets 43 Sunsets
Created on July 29, 2026

Description

Quick overview
This workflow logs Gmail receipt attachments to Google Sheets by extracting structured fields with OpenAI (including category selection from your list), prevents duplicates by checking the ledger, and sends a monthly spending summary email via Gmail based on last month’s rows.

How it works
Triggers when a Gmail message matching has:attachment subject:receipt arrives or when a schedule runs on the 1st of the month at 8am.
For receipt emails, looks up the Gmail message ID in Google Sheets and stops if the receipt is already logged.
If the receipt is new, extracts text from PDF attachments or transcribes image receipts using OpenAI vision.
Sends the receipt text to OpenAI to extract receipt_date, merchant, amount, currency, and a category chosen only from your predefined category list.
Appends one cleaned expense row to Google Sheets with the extracted fields plus a processed timestamp, Gmail message ID, and the original email subject.
For the monthly run, reads the full Google Sheets ledger, totals last month’s expenses by category, and emails the summary to you via Gmail.

Setup
Connect Gmail credentials for the Gmail Trigger and for sending the monthly summary email.
Connect Google Sheets credentials and select the target spreadsheet and sheet in the lookup, append, and read operations.
Add an OpenAI API key for the OpenAI vision transcription and the structured extraction steps, and confirm the chosen model (for example, gpt-4o-mini).
Create a Google Sheet with headers processed_at, gmail_message_id, receipt_date, merchant, amount, currency, category, source_subject so the lookup and append operations map correctly.
Update the settings values for your recipient email address, default currency, category list, and (optionally) the Gmail search query to match your labeling or subject conventions.

Additional info
⚠️ Known issues in this version (honest notes — fixes in preparation)

After selecting your own spreadsheet in the three Google Sheets nodes (as the setup note asks), n8n can silently clear those nodes' column mappings. Receipts then land as empty rows or the append fails — and because the Gmail trigger doesn't re-deliver, that receipt will never be recorded (AI extraction still runs and is billed). After selecting your sheet, re-open each Sheets node, confirm the column mapping is intact, and send yourself one test receipt before trusting it.

In timezones west of UTC (the Americas), receipts dated the 1st of a month can drop out of that month's summary, and the 1st of the following month can be included by mistake.

Only PDF and image attachments are processed — other formats (e.g., iPhone HEIC) are silently ignored. Convert to JPEG/PDF first.

The summary email retries on failure and can, rarely, arrive twice (it only goes to you).

Nodes Used (7)

Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm
Code
n8n-nodes-base.code
Gmail
n8n-nodes-base.gmail
Google Sheets
n8n-nodes-base.googleSheets
OpenAI
@n8n/n8n-nodes-langchain.openAi
OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi
Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured