See llms.txt for all machine-readable content.

Back to Templates

Log email receipts to Google Sheets with Gmail and OpenAI

Created by

Created by: 43 Sunsets || the43sunsets
43 Sunsets

Last update

Last update 5 hours ago

Categories

Share


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

  1. Triggers when a Gmail message matching has:attachment subject:receipt arrives or when a schedule runs on the 1st of the month at 8am.
  2. For receipt emails, looks up the Gmail message ID in Google Sheets and stops if the receipt is already logged.
  3. If the receipt is new, extracts text from PDF attachments or transcribes image receipts using OpenAI vision.
  4. Sends the receipt text to OpenAI to extract receipt_date, merchant, amount, currency, and a category chosen only from your predefined category list.
  5. Appends one cleaned expense row to Google Sheets with the extracted fields plus a processed timestamp, Gmail message ID, and the original email subject.
  6. 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

  1. Connect Gmail credentials for the Gmail Trigger and for sending the monthly summary email.
  2. Connect Google Sheets credentials and select the target spreadsheet and sheet in the lookup, append, and read operations.
  3. 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).
  4. 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.
  5. 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.