ChatGPTMoneyLower billsAI score · PendingAI-assisted edit · no obvious prompt-injection riskn8n.io

Automated PDF Invoice Processing & Approval Flow (n8n + OpenAI + Google Sheets)

PDF invoice → text extraction → GPT structured parsing → email approval → Google Sheets logging

Some experienceStepsWorkflowPromptTip
Who
Finance teams and ops managers at SMBs who need automated invoice intake and approval audit trails
You get
Receive PDF invoices via Drive, Gmail, or form; AI extracts fields and categories; email form approval; auto-write to Google Sheets
You need
n8n · google-drive · gmail · google-sheets

Constraints

Prerequisites: n8n instance; Google Drive, Gmail, Google Sheets OAuth2 credentials; OpenAI API Key. Copy the author’s Google Sheet template first. Input is a PDF invoice file; output is a Google Sheets row with approval status. Costs depend on OpenAI API usage and n8n hosting.

What they did

Author Billy Christi published an n8n workflow template demonstrating automated PDF invoice processing. The template ingests PDFs via Google Drive folder monitoring, Gmail attachment listening, or an n8n form; extracts text with Extract from File nodes; parses structured data (invoice number, vendor, amount, tax, category) using GPT-4o-mini with a JSON schema; sends an embedded-form approval email via Gmail sendAndWait; and writes results to Google Sheets or sends a rejection alert based on the reviewer’s decision.

How it went

The author states the template enables end-to-end automated invoice approval and bookkeeping, reduces manual entry errors, and uses a structured JSON schema for consistent AI output. (Source: template description and sticky notes; not tested by this site.)

Worth knowing

1) No operational data or ROI from real-world usage is provided by the source. 2) Default model is gpt-4o-mini; gpt-4o or gpt-4 can be selected in the node. 3) Approval email recipients must be configured manually; default placeholder is [email protected]. 4) The Google Sheet template must be copied externally and its document ID replaced. 5) Input sources poll every minute, which may incur Google API usage. 6) Both rejected and approved records are written to the same Google Sheet, distinguished only by the Approved column. 7) Poor-quality or non-standard PDF scans may cause extraction errors; human review is advised.

n8n workflow template

Structure checked · Not run-tested

Use “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.

Setup and test checklist

Credentials to connect

  • OpenAI Chat Model node: connect OpenAI API credentials.
  • Invoice Folder Monitor node: connect Google Drive OAuth2 credentials.
  • Download Invoice PDF node: connect Google Drive OAuth2 credentials.
  • Insert Invoice Data node: connect Google Sheets OAuth2 credentials.
  • Send Invoice for Approval node: connect Gmail OAuth2 credentials.
  • Monitor Email Attachments node: connect Gmail OAuth2 credentials.
  • Send Rejection Alert node: connect Gmail OAuth2 credentials.

Configuration to replace

  • Source template is n8n public workflow #4452 (~18 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
  • Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.

Test input and expected output

  • Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
  • Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.

Template changes

  • Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
  • No business-logic edits; verify keys, quotas and privacy compliance before use.

Template retrieved: 2026-10-24

Steps

  1. Configure input channels and credentials

    Set up one or all three triggers in n8n: 1) Google Drive Trigger: specify folder ID to watch (fileCreated, poll every minute); 2) Gmail Trigger: enable downloadAttachments with prefix attachment_; 3) Form Trigger: add a file field restricted to .pdf. Connect Google Drive, Gmail, Google Sheets OAuth2 credentials and OpenAI API Key.

  2. Configure the AI parser node

    Add an AI Agent node (Invoice Parser AI Agent), connect OpenAI Chat Model (default gpt-4o-mini) and Structured Output Parser. Paste the system prompt into the agent’s text field to extract invoice fields and categorize.

    Execution prompt · Source text。Invoice Parser AI Agent node text parameter (promptType=define)

    =You are an intelligent invoice parser. I will give you raw text extracted from a PDF invoice. 
    
    ========================
    START OF RAW INVOICE TEXT
    
    {{ $json.text }}
    
    END OF RAW INVOICE TEXT
    ========================
    
    Your job is to:
    
    1. Extract key information from the invoice such as:
       - invoice_number
       - invoice_date
       - due_date (if available)
       - vendor_name
       - total_amount
       - currency (e.g., USD, IDR, etc.)
       - items (as a list of item descriptions and their amounts)
       - tax (if available)
    
    2. Detect the invoice **category**, such as:
       - Utilities
       - Office Supplies
       - Travel
       - Software
       - Food & Beverage
       - Others (if unknown)
    
    3. Return the result in this exact JSON format:
    
    ```json
    {
      "invoice_number": "",
      "invoice_date": "",
      "due_date": "",
      "vendor_name": "",
      "total_amount": "",
      "currency": "",
      "items": [
        {
          "description": "",
          "amount": ""
        }
      ],
      "tax": "",
      "category": ""
    }
  3. Set up the approval email

    Add a Gmail node (Send Invoice for Approval), set operation to sendAndWait and responseType to customForm. Configure recipient address, subject (with vendor name variable), and form fields: dropdown Approve Invoice? (Yes/No), required text Reviewed By, textarea Approval Notes.

  4. Configure approval branching

    Add an If node (Check Approval Decision), condition: $json.data['Approve Invoice?'] equals Yes. True branch → Google Sheets append; False branch → rejection alert email.

  5. Configure logging and rejection alert

    Google Sheets node (Insert Invoice Data): operation=append, specify document ID and sheet name, map fields Invoice Number, Date, Due Date, Vendor, Total, Currency, Items, Tax, Category, Approved, Approval Notes, Reviewed By from AI Agent output and approval form data. Rejection branch: Gmail node (Send Rejection Alert) sends plain-text email to finance team with vendor name, reviewer, and notes.

Prompt you can copy

Setup guidance · Editorial suggestion。Give to setup assistant; confirm inputs and permissions first

This block is the prompt. Ads are never placed here.

You are an n8n workflow setup assistant. The user wants to replicate the Automated PDF Invoice Processing & Approval Flow. Assist in this order: 1) Confirm they have an n8n instance, Google OAuth credentials, and an OpenAI API Key; 2) Guide them to import the workflow JSON or build manually; 3) Emphasize copying the Google Sheet template and updating the document ID; 4) Remind them to replace [email protected] with real recipients; 5) Suggest testing end-to-end with a sample PDF first. Do not execute any API calls or send real emails on their behalf.

Replace all credential placeholders and recipient addresses before activating the workflow.

Source

Automated PDF invoice processing & approval flow using OpenAI and Google Sheets · billy · n8n.io · 2025-05-28

Comments & feedback

Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.

Loading…

    Related