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.

n8n

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.
$14.99
Last updated October 3, 2026
30-day money-back guarantee
Instant download
Lifetime updates included

New buyers can create an account from the cart to unlock a controlled $10 first-purchase credit on eligible orders of $25+.

Secure checkout powered by Stripe

Support

How to import this workflow into n8n

  1. 1Purchase or download the workflow to get the n8n workflow JSON file.
  2. 2In your n8n instance, open Workflows and choose "Import from File" (or paste the JSON with Ctrl+V on the canvas).
  3. 3Open each node marked with a credential warning and connect your own accounts and API keys.
  4. 4Run the workflow once manually to verify the data flow, then toggle it to Active.

Related File & Document Management workflows

Need this deployed? We'll set it up for you.

Our automation experts deploy this workflow in your stack, connect your accounts, and verify it works — or build a custom solution from scratch.