🧾 Process and log Gmail invoices with GPT-4.1-mini, Google Sheets, and Drive

⚡ 6 views · 🧾 Invoice Processing

Description

Quick overview

This workflow runs daily, fetches unread Gmail messages, uses OpenAI (GPT-4.1-mini) to classify and extract invoice/receipt fields (including PDF text), saves PDF attachments to Google Drive, logs invoices/receipts to Google Sheets, and emails a daily digest summary.

How it works

  1. Runs every day at 7 AM on a schedule.
  2. Reads existing invoice rows from Google Sheets and fetches unread messages from Gmail.
  3. Converts each email body to plain text, extracts text from the first attached PDF (when present), and merges it into a single analysis text.
  4. Sends the combined email/PDF text to OpenAI (GPT-4.1-mini) to classify the message as invoice/receipt/other and extract structured fields.
  5. Deduplicates invoices against existing Google Sheets entries, matches receipt emails to unpaid invoices, and decides whether to append new rows or update paid status.
  6. Uploads PDF attachments to Google Drive (when required) and records the resulting file links.
  7. Marks processed Gmail messages as read, applies a processed label, updates Google Sheets (append invoices/receipts or mark invoices paid), and sends a formatted daily digest email via Gmail.

Setup

  1. Add credentials for Gmail, Google Sheets, and Google Drive, and ensure the workflow has access to the mailbox, spreadsheet, and Drive folder you want to use.
  2. Add an OpenAI credential for the OpenAI Chat Model node and confirm the AI model is connected to the extraction chain after importing.
  3. Update the configuration values (digest recipient email, Google Sheets spreadsheet ID and sheet names, Google Drive folder ID/URL, and the Gmail processed label ID) in the configuration step before activating the workflow.

Requirements

Customization

Additional info

This workflow uses LangChain/community nodes and requires self-hosted n8n. For support, contact support@ais.email (AI Solutions, Inc.).

🔗 Nodes Used

Google Sheets, Google Drive, Gmail, Schedule Trigger, Filter, Basic LLM Chain

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup