Skip to main content

Extract & classify invoices & receipts with Gmail, OpenAI and Google Drive

Workflow preview

Workflow preview
100%
Extract & classify invoices & receipts with Gmail, OpenAI and Google Drive 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 is it for? Anyone who wants to automatically aggregate their invoices or receipts. Main beneficiaries: small business owners and freelancers. How it works 1. Creates a folder in Google Drive fo...

Best for

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

Tools used

@n8n/n8n-nodes-langchain.openai, n8n-nodes-base.set, n8n-nodes-base.code, n8n-nodes-base.noop, n8n-nodes-base.if, n8n-nodes-base.merge, n8n-nodes-base.googledrive, n8n-nodes-base.webhook

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Extract & classify invoices & receipts with Gmail, OpenAI and Google Drive
Workflow name
Extract & classify invoices & receipts with Gmail, OpenAI and Google Drive

Who is it for?

Anyone who wants to automatically aggregate their invoices or receipts. Main beneficiaries: small business owners and freelancers.

How it works

  1. Creates a folder in Google Drive for uploading invoices and receipts. Responds (Webhook response) with URL to the created folder.
  2. Gets all emails with attachments from a Gmail mailbox.
  3. (Optional) Filters emails, e.g. exclude emails sent to specific address.
  4. Filters only PDF attachments.
  5. Classifies all PDF attachment contents with an AI model (is it a receipt or an invoice?).
  6. Uploads receipts and invoices to the created Google Drive folder and optionally sends an email with the attachments to, e.g., your accountant.

Pre-conditions/Requirements

  • Gmail and Google Drive accounts
  • A Google Cloud OAuth 2.0 Client ID or a service account with Google Drive and Gmail APIs enabled
  • OpenAI API account and API key

Set up steps

  1. Provide credentials for the nodes: Gmail, Google Drive, OpenAI.
  2. Configure parameters in the "Configure" node. Most importantly:
    • "sendInvoicesTo" for the email address where invoices/receipts should be sent.
  3. It uses a Webhook node trigger. It expects a body with a schema such as:
{
  "name": "getInvoicesAndReceiptsFromEmails",
  "description": "Finds and uploads to Google Drive all receipts and invoices from emails within a specified date range.",
  "parameters": {
    "type": "object",
    "properties": {
      "startDate": {
        "type": "string",
        "format": "date-time",
        "description": "The start date of the range to search for emails. Must be in ISO 8601 format."
      },
      "endDate": {
        "type": "string",
        "format": "date-time",
        "description": "The end date of the range to search for emails. Must be in ISO 8601 format."
      },
      "sendEmail": {
        "type": "boolean",
        "description": "Indicates whether to send an email with all receipts and invoices after processing. Must be true or false."
      }
    },
    "required": [
      "startDate",
      "endDate"
    ]
  }
}

Example body:

{
  "startDate": "2025-03-01T00:00:00Z",
  "endDate": "2025-04-01T00:00:00Z",
  "sendEmail": true
}

How to use with AI chat

You can trigger the workflow with an AI chat that supports tool use, such as BrowseWiz. For setup instructions, read the blog post.

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

Type / Role
@n8n/n8n-nodes-langchain.openAi - openAi
Config choices
Version 1.8

Block 2 - Configure

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

Block 3 - Iterate over email attachments

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

Block 4 - Not a PDF

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

Block 5 - Is text within token limit?

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

Block 6 - Merge

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

Block 7 - Is matched

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

Block 8 - Upload file to folder

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

Block 9 - Webhook

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

Block 10 - Respond to Webhook

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

Block 11 - Create folder

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

Block 12 - Aggregate attachments

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

Block 13 - Send email with invoices?

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

Block 14 - Send to my accountant

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

Block 15 - Get emails with attachments

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

Block 16 - Read PDF email attachments

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

Block 17 - Is attachment a PDF?

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

Block 18 - Optional filter for emails

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

Block 19 - Sticky Note

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

Block 20 - Sticky Note1

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

3. Summary Table

Workflow Extract & classify invoices & receipts with Gmail, OpenAI and Google Drive
Complexity advanced
Nodes 20
Categories Invoice Processing, AI Summarization
Author Tom
Published 26 Apr 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/3719/3719.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 & classify invoices & receipts with Gmail, OpenAI and Google Drive do?

Who is it for? Anyone who wants to automatically aggregate their invoices or receipts. Main beneficiaries: small business owners and freelancers. How it works 1. Creates a folder in Google Drive fo...

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.