Skip to main content

Extract & organize email invoices with Gmail, Drive & OpenAI GPT

Workflow preview

Workflow preview
100%
Extract & organize email invoices with Gmail, Drive & OpenAI GPT preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Who’s it for This template is for founders, finance teams, and solo operators who receive lots of invoices by email and want them captured automatically in a single, searchable source of truth. If ...

Best for

  • Invoice Processing automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.outputparserstructured, n8n-nodes-base.noop, n8n-nodes-base.gmailtrigger, n8n-nodes-base.googledrive, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.extractfromfile, n8n-nodes-base.if

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Feras Dabour.

Original n8n.io source

1.1 Workflow description

Title
Extract & organize email invoices with Gmail, Drive & OpenAI GPT
Workflow name
Extract & organize email invoices with Gmail, Drive & OpenAI GPT

Who’s it for

This template is for founders, finance teams, and solo operators who receive lots of invoices by email and want them captured automatically in a single, searchable source of truth. If you’re tired of hunting through your inbox for invoice PDFs or “that one receipt from three months ago,” this is for you.

What it does / How it works

The workflow polls your Gmail inbox on a schedule and fetches new messages including their attachments. A JavaScript Code node restructures all attachments, and a PDF extraction node reads any attached PDFs.
An AI “Invoice Recognition Agent” then analyzes the email body and attachments to decide whether the email actually contains an invoice. If not, the workflow stops.

If it is an invoice, a second AI “Invoice Data Extractor” pulls structured fields such as date_email, date_invoice, invoice_nr, description, provider, net_amount, vat, gross_amount, label (saas/hardware/other), and currency. Depending on whether the invoice is in an attachment or directly in the email text, the workflow either:

  • uploads the invoice file to Google Drive, or
  • document a direct link to the mail,

then appends/updates a row in Google Sheets with all invoice parameters plus a Drive link, and finally marks the Gmail message as read.

How to set up

  1. Add and authenticate:
    • Gmail credentials
    • Google Sheets credentials
    • Google Drive credentials
    • OpenAI (or compatible) credentials for the AI nodes
  2. Create or select a Google Sheet with the expected columns (date_email, date_invoice, invoice_nr, description, provider, net_amount, vat, gross_amount, label, currency, link).
  3. Create or select a Google Drive folder where invoices/docs should be stored.
  4. Adjust the Gmail Trigger filters (labels, search query, polling interval) to match the mailbox you want to process.
  5. Update node credentials and resource IDs (Sheet, Drive folder) via the node UIs, not hardcoded in HTTP nodes.

Requirements

  • n8n instance (cloud or self-hosted)
  • Gmail account with OAuth2 setup
  • Google Drive and Google Sheets access
  • OpenAI (or compatible) API key configured in n8n
  • Sufficient permissions to read emails, read/write Drive files, and edit the target Sheet

How to customize the workflow

  • Change invoice categories: Extend the label enum (e.g., add “services”, “subscriptions”) in the extraction schema and adjust any downstream logic.
  • Refine invoice detection: Tweak the AI prompts to be more or less strict about what counts as an invoice or receipt.
  • Add notifications: After updating the Sheet, send a Slack/Teams message or email summary for high-value invoices.
  • Filter by sender or subject: Narrow the Gmail Trigger to specific vendors, labels, or keywords.
  • Extend the data model: Add fields (e.g., cost center, project code) to the extractor prompt and Sheet mapping to fit your bookkeeping setup.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.3

Block 2 - Structured Output Parser

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 3 - No Operation, do nothing

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 4 - OpenAI Chat Model1

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.3

Block 5 - Structured Output Parser1

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 6 - Gmail Trigger

Type / Role
n8n-nodes-base.gmailTrigger - gmailTrigger
Config choices
Version 1.3

Block 7 - Upload file

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 8 - Invoice Recognition Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 3

Block 9 - Invoice Data extractor

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 3

Block 10 - Extract from File

Type / Role
n8n-nodes-base.extractFromFile - extractFromFile
Config choices
Version 1.1

Block 11 - Check wether it is an invoice

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 12 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Check wether it was a file-invoice or text invoice

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 17 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 19 - Document the invoice parameters

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 20 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 21 - Update Invoice parameters

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 22 - Update text Invoice parameters

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 23 - Mark a message as read

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 24 - Code in JavaScript

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Showing the first 24 of 28 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Extract & organize email invoices with Gmail, Drive & OpenAI GPT
Complexity advanced
Nodes 28
Categories Invoice Processing, AI Summarization
Author Feras Dabour
Published 26 Dec 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/12173/12173.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Extract & organize email invoices with Gmail, Drive & OpenAI GPT do?

Who’s it for This template is for founders, finance teams, and solo operators who receive lots of invoices by email and want them captured automatically in a single, searchable source of truth. If ...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Invoice Processing, AI Summarization use case.