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).
Related Templates
AI Email Classifier & Auto-Delete for Gmail (SPAM/OFFER Cleaner)
This workflow is designed for freelancers, solopreneurs, and business owners who receive a high volume of irrelevant mes...
Generate Product Ad Copy & CTAs with GPT-4 for Slack and Airtable
⚡ AI Copywriter Pro: Instant Ad Copy & CTA Generator Transform product details into compelling marketing copy in second...
Auto-classify Gmail emails with AI and apply labels for inbox organization
Who is this for? Professionals and individuals who receive high volumes of emails, those who want to automatically organ...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments