Skip to main content

Automate invoice processing with OCR.Space, GPT-4 & Google Drive to Gmail

Workflow preview

Workflow preview
100%
Automate invoice processing with OCR.Space, GPT-4 & Google Drive to Gmail preview
Open on n8n.io

Important notice

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

1. Workflow Overview

How it works Watches a Google Drive folder for new (scanned) invoices. Each new file automatically triggers the workflow. Downloads and processes each invoice through OCR Space to extract the text....

Best for

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

Tools used

n8n-nodes-base.merge, n8n-nodes-base.splitinbatches, n8n-nodes-base.httprequest, n8n-nodes-base.googledrive, n8n-nodes-base.googlesheetstool, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.set

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Automate invoice processing with OCR.Space, GPT-4 & Google Drive to Gmail
Workflow name
Automate invoice processing with OCR.Space, GPT-4 & Google Drive to Gmail

How it works

  • Watches a Google Drive folder for new (scanned) invoices. Each new file automatically triggers the workflow.
  • Downloads and processes each invoice through OCR Space to extract the text.
  • Extracts the company name (e.g. from the “billed to” field) and uses an AI agent to cross-reference it against a database in Google Sheets.
  • If a match is found, retrieves the correct recipient email and sends the invoice as an attachment.
  • If no match or an error occurs, the workflow alerts an operator by email for manual review.

Setting up the workflow

  1. Connect Google Drive • In n8n, connect your Google Drive account. • Create or select a folder where you will upload scanned invoices.

  2. Connect Gmail (or another email service) • Add your Gmail account as a credential in n8n. • This will be used to send the processed invoice to the correct recipient.

  3. Set up OCR.Space • Create a free OCR.Space account: https://ocr.space • In n8n, create a Generic Credential (Header Auth). • Use apikey as the name and your OCR API key as the value.

  4. Connect the AI Agent • Add your OpenAI API key as a credential in n8n. • The AI Agent will extract the company name from the invoice text and match it against your database. • If a match is found, it retrieves the correct email.

  5. Prepare the Google Sheet database • Make a copy of the database sheet: Google Sheet Template • Fill it with company names and recipient emails. • Connect your Google account to n8n and link this sheet to the workflow.

  6. Run the workflow • When a new invoice is uploaded to your Google Drive folder, the workflow will: • Extract the text with OCR.Space • Use the AI Agent to identify the company name • Cross-reference it with your Google Sheet database • Send the invoice automatically to the correct recipient via Gmail • If no match is found, an error email is sent to you for manual review

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 - Merge

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

Block 2 - Loop Over Items

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

Block 3 - HTTP Request1

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 4 - Google Drive

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

Block 5 - Google Sheets

Type / Role
n8n-nodes-base.googleSheetsTool - googleSheetsTool
Config choices
Version 4.5

Block 6 - OpenAI Chat Model

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

Block 7 - AI Agent

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

Block 8 - Edit Fields

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

Block 9 - Code

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

Block 10 - No Operation, do nothing

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

Block 11 - Merge1

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

Block 12 - No Operation, do nothing1

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

Block 13 - Error

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

Block 14 - Send Email

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

Block 15 - Error1

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

Block 16 - If

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

Block 17 - Structured Output Parser1

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

Block 18 - Sticky Note1

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

Block 19 - Sticky Note2

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

Block 20 - Sticky Note3

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

Block 21 - Sticky Note4

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

Block 22 - Sticky Note5

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

Block 23 - Sticky Note6

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

Block 24 - Sticky Note7

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

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

3. Summary Table

Workflow Automate invoice processing with OCR.Space, GPT-4 & Google Drive to Gmail
Complexity advanced
Nodes 29
Categories Invoice Processing, AI Summarization
Author Michael Taleb
Published 02 Sept 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/8139/8139.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 Automate invoice processing with OCR.Space, GPT-4 & Google Drive to Gmail do?

How it works Watches a Google Drive folder for new (scanned) invoices. Each new file automatically triggers the workflow. Downloads and processes each invoice through OCR Space to extract the text....

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.