AutomationFlowsAI & RAG › Extract and Process Invoices with Gpt-4, Google Drive, and Google Sheets

Extract and Process Invoices with Gpt-4, Google Drive, and Google Sheets

ByWolfgang Renner @naviqo on n8n.io

This template is a fully automated AI invoice processing workflow for n8n. It watches a Google Drive folder for new invoice PDFs, extracts all key information using an AI Agent, assigns the correct booking account, saves the renamed invoice in the right Drive folder, and updates…

Event trigger★★★★☆ complexityAI-powered17 nodesGoogle SheetsGoogle Sheets ToolGoogle DriveOutput Parser StructuredOpenAI ChatMemory Buffer WindowGoogle Drive TriggerAgent
AI & RAG Trigger: Event Nodes: 17 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #11058 — we link there as the canonical source.

This workflow follows the Agent → Google Drive recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "t1HT03DygW2XemQU",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Invoice Agent Basic",
  "tags": [
    {
      "id": "2p90ymjY5pMU4FHE",
      "name": "Invoices",
      "createdAt": "2025-11-20T15:37:22.981Z",
      "updatedAt": "2025-11-20T15:37:22.981Z"
    },
    {
      "id": "9ygvGEs0K1iWZqWd",
      "name": "Google Sheets",
      "createdAt": "2025-11-20T15:37:52.842Z",
      "updatedAt": "2025-11-20T15:37:52.842Z"
    },
    {
      "id": "obdX3FBn0XonUCJt",
      "name": "Google Drive",
      "createdAt": "2025-11-20T15:37:59.205Z",
      "updatedAt": "2025-11-20T15:37:59.205Z"
    }
  ],
  "nodes": [
    {
      "id": "fd00aab8-c276-4097-8c11-79ae2dd517d6",
      "name": "Update Booking List",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        240,
        304
      ],
      "parameters": {
        "columns": {
          "value": {
            "vendor": "={{ $json.output.vendor }}",
            "currency": "={{ $json.output.currency }}",
            "invoice date": "={{ $json.output.invoiceDate }}",
            "total amount": "={{ $json.output.totalAmount }}",
            "invoice number": "={{ $json.output.invoiceNumber }}",
            "booking account": "={{ $json.output.bookingAccount }}",
            "invoice descripton": "={{ $json.output.bookingText }}"
          },
          "schema": [
            {
              "id": "invoice date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "invoice date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "vendor",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "vendor",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "total amount",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "total amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "currency",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "currency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": " my currency",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": " my currency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "invoice number",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "invoice number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "invoice descripton",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "invoice descripton",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "booking account",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "booking account",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1eOAvuaURbQe-e5XZwGcafrOOdEZf8nl5Gnh_gDJ0p88/edit#gid=0",
          "cachedResultName": "booking list"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1eOAvuaURbQe-e5XZwGcafrOOdEZf8nl5Gnh_gDJ0p88",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1eOAvuaURbQe-e5XZwGcafrOOdEZf8nl5Gnh_gDJ0p88/edit?usp=drivesdk",
          "cachedResultName": "booking list"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "8f2b4852-5d79-41d8-bda5-8d08d3135eee",
      "name": "Chart of Accounts",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -80,
        384
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 2104487111,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1eOAvuaURbQe-e5XZwGcafrOOdEZf8nl5Gnh_gDJ0p88/edit#gid=2104487111",
          "cachedResultName": "booking accounts"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1eOAvuaURbQe-e5XZwGcafrOOdEZf8nl5Gnh_gDJ0p88",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1eOAvuaURbQe-e5XZwGcafrOOdEZf8nl5Gnh_gDJ0p88/edit?usp=drivesdk",
          "cachedResultName": "booking list"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "eb0a252a-449a-4e98-8959-5a0decd3f9bf",
      "name": "Save to Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        464,
        -16
      ],
      "parameters": {
        "name": "={{ $json.output.invoiceDate2 }} {{ $json.output.vendor }}.pdf",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.output.folderID }}"
        },
        "inputDataFieldName": "=data"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "dac8d0b8-93a0-459e-9d56-370cbb19cf31",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        48,
        304
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"invoiceDate\": {\n      \"type\": \"string\",\n      \"description\": \"Invoice date in format MM/DD/YY (e.g. 09/12/25)\",\n      \"pattern\": \"^\\\\d{2}/\\\\d{2}/\\\\d{2}$\"\n    },\n    \"invoiceDate2\": {\n      \"type\": \"string\",\n      \"description\": \"Invoice date in format YYMMDD (e.g. 250912)\",\n      \"pattern\": \"^\\\\d{6}$\",\n      \"minLength\": 6,\n      \"maxLength\": 6\n    },\n    \"bookingAccount\": {\n      \"type\": \"number\",\n      \"description\": \"Booking account code from the Google Sheet\"\n    },\n    \"totalAmount\": {\n      \"type\": \"number\",\n      \"description\": \"Total invoice amount\"\n    },\n    \"currency\": {\n      \"type\": \"string\",\n      \"description\": \"Invoice currency\"\n    },\n    \"invoiceNumber\": {\n      \"type\": \"string\",\n      \"description\": \"Invoice number\"\n    },\n    \"bookingText\": {\n      \"type\": \"string\",\n      \"description\": \"Description or booking text\"\n    },\n    \"vendor\": {\n      \"type\": \"string\",\n      \"description\": \"Vendor/Supplier name\"\n       },\n    \"folderID\": {\n      \"type\": \"string\",\n      \"description\": \"Google Drive Folder ID from the Google Sheet\"\n    }\n  },\n  \"required\": [\"invoiceDate\", \"invoiceDate2\", \"konto\", \"vendor\", \"folderID\"]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "467f0abc-72a8-40bb-b7a5-9ab3be3b1860",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -368,
        304
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7e397cb2-0e27-4f26-a9cb-156e1d102315",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -576,
        80
      ],
      "parameters": {
        "options": {
          "keepSource": "both"
        },
        "operation": "pdf",
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1
    },
    {
      "id": "f1e5c8f3-8553-4f21-bcc8-1fbf86c55e3f",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -224,
        384
      ],
      "parameters": {
        "sessionKey": "={{ $('Google Drive Trigger').item.json.id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "61d21596-de54-42d8-8ed3-5f8d7c77410a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1104,
        -32
      ],
      "parameters": {
        "color": 7,
        "width": 674,
        "height": 272,
        "content": "## INPUT\n### Upload Invoice PDF from Google Drive Input Folder and Extract the data from the PDF binary file"
      },
      "typeVersion": 1
    },
    {
      "id": "f857416b-532a-421c-8f33-652345df1c65",
      "name": "Google Drive Trigger",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -1024,
        80
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1YvZXJugBrB1AaJnSFWFfgQ4gJEpDWLks",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1YvZXJugBrB1AaJnSFWFfgQ4gJEpDWLks",
          "cachedResultName": "Input AI Invoice Agent"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5ef8bac9-10a9-4bda-8b0a-79b737a25da2",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        240,
        -16
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e4207d24-9726-418b-aaaa-da25fe874bb1",
              "name": "data",
              "type": "binary",
              "value": "={{ $('Download file').item.binary.data }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "ef35f983-2aea-472f-ad07-4b565cfdb960",
      "name": "Move file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        464,
        304
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Google Drive Trigger').item.json.id }}"
        },
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1_M0f6Ms1wvTVmu3Set5ybiXa2fkfmmkc",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1_M0f6Ms1wvTVmu3Set5ybiXa2fkfmmkc",
          "cachedResultName": "Output Invoice Agent"
        },
        "operation": "move"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "e1e44f35-6e19-4d02-a99f-268cb98236f4",
      "name": "Download file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -800,
        80
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "a765240d-5e8f-4438-9078-1813a13f72cc",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -144
      ],
      "parameters": {
        "color": 7,
        "width": 482,
        "height": 288,
        "content": "## OUTPUT\n### Saving Invoice with new filename (YYMMDD vendor) as PDF-File in the according folder (matching to the booking account) "
      },
      "typeVersion": 1
    },
    {
      "id": "f4fa17ab-87ee-446d-b1d7-913f748665af",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 578,
        "height": 640,
        "content": "## AI AGENT\n### reading relevant information (vendor, bookingtext, amount, currency etc.) from the invoice, and matching the correct booking account.\n### The output parser set the defined variables."
      },
      "typeVersion": 1
    },
    {
      "id": "e4b1c13c-110f-4e63-8320-1470d27389d2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1568,
        0
      ],
      "parameters": {
        "color": 5,
        "width": 448,
        "height": 496,
        "content": "# INVOICE AGENT BASIC\n\n## AI-Powered Invoice Extraction & Google Drive Automation\n\nThis workflow processes PDF incoming invoices from an input folder and extracts all relevant data. It checks the correct booking account and assigns the invoice to the corresponding storage directory. In doing so, it renames the file to the format (YYMMDD Vendor).pdf.\n\nThe chart of accounts can be customised in the corresponding Google Sheet so that everyone can find the chart of accounts they need.\n\n### Credentials:\n- Google Drive\n- Google Sheets\n- Open AI (GPT 4.0 mini)"
      },
      "typeVersion": 1
    },
    {
      "id": "fe5e5972-7936-454b-95d4-5b26fc9842e2",
      "name": "Invoice Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "onError": "continueRegularOutput",
      "position": [
        -240,
        80
      ],
      "parameters": {
        "text": "=Invoice: {{ $json.text }}",
        "options": {
          "systemMessage": "You are a helpful booking assistant that extracts relevant information from invoices.\n\nTo assign the invoice content to the correct booking account and the matching Google Drive folder for that account, use the tool \"booking accounts\""
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "11412f72-a43e-4136-8b97-163c69f860bd",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 482,
        "height": 304,
        "content": "## OUTPUT\n### Updating the Booking list with actual Invoice by upending a new row\n### Move the processed invoice to the output folder. "
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "27213dc9-59b5-4a71-8963-7fddf4cd10b9",
  "connections": {
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Save to Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Invoice Agent": {
      "main": [
        [
          {
            "node": "Update Booking List",
            "type": "main",
            "index": 0
          },
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Invoice Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Chart of Accounts": {
      "ai_tool": [
        [
          {
            "node": "Invoice Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Invoice Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Invoice Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Update Booking List": {
      "main": [
        [
          {
            "node": "Move file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Invoice Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This template is a fully automated AI invoice processing workflow for n8n. It watches a Google Drive folder for new invoice PDFs, extracts all key information using an AI Agent, assigns the correct booking account, saves the renamed invoice in the right Drive folder, and updates…

Source: https://n8n.io/workflows/11058/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This comprehensive n8n workflow automates the entire Meta (Facebook/Instagram) advertising process, from asset analysis to ad creation. It combines AI-powered content analysis with automated ad deploy

Facebook Graph Api, HTTP Request, Google Drive +5
AI & RAG

This automation is designed to help you generate AI-powered music tracks, cover art, and fully rendered music videos — all triggered from a simple Telegram chat and managed via Google Sheets.

OpenAI Chat, Memory Buffer Window, Output Parser Structured +11
AI & RAG

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Output Parser Structured, Telegram, N8N Nodes Tesseractjs +14
AI & RAG

This workflow is perfect for creators, solopreneurs, and personal brands who want to consistently publish bold, high-performing content on X (Twitter) — without writing a single line themselves. After

OpenAI Chat, Memory Buffer Window, Tool Workflow +10
AI & RAG

AI Blog Publisher – Automated Blog Content Workflow This workflow is designed for individuals and teams who regularly publish content on their blog and want to automate the entire process from start t

WordPress, HTTP Request, Memory Buffer Window +9