FindPrompts
n8nData & ReportingAdvanced5 steps

Invoice PDF to Sheet Extractor

Watches an inbox for invoice PDFs, extracts vendor, amount, due date and line items with GPT vision/text parsing, and appends a clean row to your accounting Google Sheet. Kills manual invoice data entry.

GmailOpenAIGoogle Sheets

How it works

  1. 1Trigger: new email with a PDF attachment arrives
  2. 2Extract the text from the PDF attachment
  3. 3Parse invoice fields with GPT into JSON
  4. 4Append the structured row to Google Sheets
  5. 5Reply to confirm the invoice was logged

Setup

  • Connect Gmail, OpenAI and Google Sheets credentials.
  • Confirm the binary property name matches the attachment.
  • Create an Invoices sheet with the matching columns.
  • Review extractions periodically for parsing accuracy.

Workflow JSON

{
  "name": "Invoice PDF to Sheet Extractor",
  "nodes": [
    {
      "id": "in01aa",
      "name": "New Invoice Email",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [
        200,
        300
      ],
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "filters": {
          "q": "has:attachment filename:pdf subject:invoice"
        },
        "options": {
          "downloadAttachments": true
        }
      }
    },
    {
      "id": "in02bb",
      "name": "Extract PDF Text",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        420,
        300
      ],
      "parameters": {
        "operation": "pdf",
        "binaryPropertyName": "attachment_0"
      }
    },
    {
      "id": "in03cc",
      "name": "Parse Invoice",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.4,
      "position": [
        640,
        300
      ],
      "parameters": {
        "modelId": "gpt-4o",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Extract invoice fields. Return JSON: { vendor, amount, currency, dueDate, invoiceNumber }."
            },
            {
              "role": "user",
              "content": "{{ $json.text }}"
            }
          ]
        },
        "jsonOutput": true
      }
    },
    {
      "id": "in04dd",
      "name": "Append Row",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.4,
      "position": [
        860,
        300
      ],
      "parameters": {
        "operation": "append",
        "documentId": "YOUR_SHEET_ID",
        "sheetName": "Invoices",
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "vendor": "={{ $json.message.content.vendor }}",
            "amount": "={{ $json.message.content.amount }}",
            "currency": "={{ $json.message.content.currency }}",
            "dueDate": "={{ $json.message.content.dueDate }}",
            "invoiceNumber": "={{ $json.message.content.invoiceNumber }}"
          }
        }
      }
    },
    {
      "id": "in05ee",
      "name": "Confirm Reply",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1080,
        300
      ],
      "parameters": {
        "resource": "message",
        "operation": "reply",
        "messageId": "={{ $('New Invoice Email').item.json.id }}",
        "message": "Invoice logged: {{ $('Parse Invoice').item.json.message.content.invoiceNumber }}",
        "options": {}
      }
    }
  ],
  "connections": {
    "New Invoice Email": {
      "main": [
        [
          {
            "node": "Extract PDF Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract PDF Text": {
      "main": [
        [
          {
            "node": "Parse Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Invoice": {
      "main": [
        [
          {
            "node": "Append Row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append Row": {
      "main": [
        [
          {
            "node": "Confirm Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "meta": {}
}

Command Palette

Search for a command to run...