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).