Extract invoice data from Gmail PDF attachments to Google Sheets with GPT-4.1-mini

Quick overview This workflow checks Gmail everyday for emails with invoice-related keywords and PDF attachments, extracts the PDF text, uses OpenAI (gpt-4.1-mini) to turn the content into structured invoice fields, normalizes the result, and appends the invoice data to a Google Sheets tracker.

How it works Runs every hour and searches Gmail for messages that have attachments and match the query invoice OR bill OR receipt. Skips emails with no attachments and splits each email into individual items so each attachment is processed separately. Extracts text from each PDF attachment. Sends the extracted PDF text to an OpenAI-powered AI Agent (gpt-4.1-mini) to return invoice data as JSON. Parses and normalizes the JSON into a consistent schema (for example invoice number, dates, vendor details, totals, and tax) and converts numeric values. Appends the normalized invoice record to Google Sheets, using invoice_number as the matching column.

Setup Connect your Gmail OAuth2 credential and confirm the Gmail search query used by the trigger matches the invoices you want to process. Add an OpenAI API credential with access to the gpt-4.1-mini model (or update the model selection to one you can use). Connect your Google Sheets OAuth2 credential and select the target spreadsheet and sheet. Create or update your Google Sheet headers to match the fields being appended (for example invoice_number, date, due_date, vendor_name, subtotal, tax, and grand_total).

0
Downloads
0
Views
8.58
Quality Score
beginner
Complexity
Author:Khadija Naeem(View Original →)
Created:8/20/2026
Updated:8/20/2026

🔒 Please log in to import templates to n8n and favorite templates

Workflow Visualization

Loading...

Preparing workflow renderer

Comments (0)

Login to post comments