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

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

Ready for 3.0

by Khadija Naeem ✓ · 61 views · created 2026-08-14 · Invoice Processing, AI Summarization

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

What this workflow does

This AI workflow has 17 nodes and runs on Gmail events. Along the way it connects Gmail, Google Sheets and OpenAI Chat Model.

How it runs

Trigger: On Gmail events.

  1. If: checks a condition and branches into true / false
  2. Code: runs custom JavaScript code
  3. Check Duplicate (Code): runs custom JavaScript code
  4. Is PDF? (If): checks a condition and branches into true / false
  5. Extract from File: extracts data from a file (pdf)
  6. Flag Unsupported Format (Edit Fields (Set)): sets 4 fields: reason, file_name, from_email…
  7. AI Agent: runs an AI agent, with model: OpenAI Chat Model
  8. Log Manual Review (Google Sheets): append
  9. Parse JSON Response (Code): runs custom JavaScript code
  10. Has Error? (If): checks a condition and branches into true / false

…plus 4 more steps. See the full node list below.

Services it uses

GmailGoogle SheetsOpenAI Chat Model

Before you upgrade to n8n 3.0

Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.

Nodes used (10)

From the author

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…

Excerpt from Khadija Naeem's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.