{
  "nodes": [
    {
      "id": "836951a0-7021-483d-ad2e-d0cd30a63c1c",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        880,
        400
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1b4a7d41-bc44-4540-b41e-087dbebc119d",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1100,
        400
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"invoice_number\": \"\",\n  \"invoice_date\": \"\",\n  \"due_date\": \"\",\n  \"vendor_name\": \"\",\n  \"total_amount\": \"\",\n  \"currency\": \"\",\n  \"items\": [\n    {\n      \"description\": \"\",\n      \"amount\": \"\"\n    }\n  ],\n  \"tax\": \"\",\n  \"category\": \"\"\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "a141da9e-a7da-49e5-9b0d-c4ee80d962ca",
      "name": "Invoice Folder Monitor",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        320,
        200
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "id",
          "value": "1KJ4fvXcKVMGJunsKvPYf8PkX5K9SVwFk"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "42f9ec84-506d-4abc-ac87-fa6379ef1551",
      "name": "Download Invoice PDF",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        520,
        200
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "5e7ac15d-8dac-4d9b-814d-e10e9f9cdecd",
      "name": "PDF Text Extractor",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        720,
        200
      ],
      "parameters": {
        "options": {},
        "operation": "pdf"
      },
      "typeVersion": 1
    },
    {
      "id": "2955c643-dcf3-4902-a18d-d0a532338bba",
      "name": "Invoice Parser AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        900,
        200
      ],
      "parameters": {
        "text": "=You are an intelligent invoice parser. I will give you raw text extracted from a PDF invoice. \n\n========================\nSTART OF RAW INVOICE TEXT\n\n{{ $json.text }}\n\nEND OF RAW INVOICE TEXT\n========================\n\nYour job is to:\n\n1. Extract key information from the invoice such as:\n   - invoice_number\n   - invoice_date\n   - due_date (if available)\n   - vendor_name\n   - total_amount\n   - currency (e.g., USD, IDR, etc.)\n   - items (as a list of item descriptions and their amounts)\n   - tax (if available)\n\n2. Detect the invoice **category**, such as:\n   - Utilities\n   - Office Supplies\n   - Travel\n   - Software\n   - Food & Beverage\n   - Others (if unknown)\n\n3. Return the result in this exact JSON format:\n\n```json\n{\n  \"invoice_number\": \"\",\n  \"invoice_date\": \"\",\n  \"due_date\": \"\",\n  \"vendor_name\": \"\",\n  \"total_amount\": \"\",\n  \"currency\": \"\",\n  \"items\": [\n    {\n      \"description\": \"\",\n      \"amount\": \"\"\n    }\n  ],\n  \"tax\": \"\",\n  \"category\": \"\"\n}\n",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.9
    },
    {
      "id": "5a294233-f441-47e4-8c91-4b205db40034",
      "name": "Insert Invoice Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1240,
        200
      ],
      "parameters": {
        "columns": {
          "value": {
            "Tax": "={{ $json.output.tax }}",
            "Items": "={{ $json.output.items }}",
            "Category": "={{ $json.output.category }}",
            "Currency": "={{ $json.output.currency }}",
            "Due Date": "={{ $json.output.due_date }}",
            "Vendor Name": "={{ $json.output.vendor_name }}",
            "Invoice Date": "={{ $json.output.invoice_date }}",
            "Total Amount": "={{ $json.output.total_amount }}",
            "Invoice Number": "={{ $json.output.invoice_number }}"
          },
          "schema": [
            {
              "id": "Invoice Number",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Invoice Number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoice Date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Invoice Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Due Date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Due Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Vendor Name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Vendor Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Total Amount",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Total Amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Currency",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Currency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Items",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Items",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Tax",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Tax",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Category",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Category",
              "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/1u5dHeytao9y3L0Mgv8cSomPVLS3CMrn_eOwXW3oQ3c8/edit#gid=0",
          "cachedResultName": "Invoices"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1u5dHeytao9y3L0Mgv8cSomPVLS3CMrn_eOwXW3oQ3c8",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1u5dHeytao9y3L0Mgv8cSomPVLS3CMrn_eOwXW3oQ3c8/edit?usp=drivesdk",
          "cachedResultName": "PDF Invoice Parser - n8n template"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "1ea9e08b-5b53-4239-8687-a3d0baa8cefb",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 280,
        "height": 500,
        "content": "## SETUP REQUIRED\n**Author:** [Billy Christi](https://n8n.io/creators/billy/)\n\n**Copy the Google Sheet template here**:\n\ud83d\udc49 [PDF Invoice Parser \u2013 Google Sheet Template](https://docs.google.com/spreadsheets/d/1u5dHeytao9y3L0Mgv8cSomPVLS3CMrn_eOwXW3oQ3c8/edit?gid=0#gid=0)\n\nGoogle Sheets Structure:\nSheet: \"Invoices\"\n\u2022 Column A: Invoice Number  \n\u2022 Column B: Invoice Date  \n\u2022 Column C: Due Date  \n\u2022 Column D: Vendor Name  \n\u2022 Column E: Total Amount  \n\u2022 Column F: Currency  \n\u2022 Column G: Items  \n\u2022 Column H: Tax  \n\u2022 Column I: Category  \n\nRequired Credentials:\n\u2022 Google Drive Credential  \n\u2022 Google Sheets Credential  \n\u2022 OpenAI API Key (GPT-4)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "2e870f4d-c62d-4bbe-842d-2cd4a2b61d3c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        540
      ],
      "parameters": {
        "color": 5,
        "width": 460,
        "height": 400,
        "content": "## \ud83e\uddfe AI-Powered PDF Invoice Parser for Google Drive & Sheets\n\nWhat This Template Does:\n\n- Monitors a designated Google Drive folder for new incoming PDF invoices  \n- Automatically downloads and extracts text content from the PDFs  \n- Uses GPT-4 to intelligently parse and structure invoice data (amount, vendor, items, date, etc.)  \n- Categorizes invoices by type (Office Supplies, Food & Beverage, etc.)  \n- Saves all parsed invoice data into a Google Sheets document  \n- Fully automates invoice processing and bookkeeping for businesses  "
      },
      "typeVersion": 1
    },
    {
      "id": "3292de6d-6565-459e-995e-3c09bd256c5e",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        540
      ],
      "parameters": {
        "color": 5,
        "width": 400,
        "height": 340,
        "content": "## \ud83d\udccb WORKFLOW PROCESS OVERVIEW\n\nStep 1: \ud83d\udcc2 Invoice Folder Monitor watches a specific Google Drive folder for new PDF invoices  \nStep 2: \u2b07\ufe0f Download Invoice PDF downloads the new invoice as binary data  \nStep 3: \ud83d\udd0d PDF Text Extractor converts the PDF binary into readable text using OCR and extraction tools  \nStep 4: \ud83e\udd16 Invoice Parser AI Agent (GPT-4) analyzes the text and extracts structured invoice data in JSON format  \nStep 5: \ud83d\udcdd Insert Invoice Data appends the structured invoice data to the Google Sheets \"Invoices\""
      },
      "typeVersion": 1
    },
    {
      "id": "d3b8cf4f-b2ad-4577-99bf-e84b5c1d06de",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1460,
        -100
      ],
      "parameters": {
        "color": 4,
        "width": 380,
        "height": 760,
        "content": "# \ud83d\udc4b Hi, I\u2019m Billy\n![My Photo](https://i.ibb.co/Gvn63Bzc/Billy-Christi-AI-Automation.jpg)\nI help businesses build **n8n workflows** & **AI automation projects**.  \nNeed help with n8n or AI Automation projects? \nContact me and let\u2019s build your automation together.\n\n\ud83d\udce9 **Email:** billychartanto@gmail.com  \n\ud83e\udd1d **n8n Creator:** [n8n.io/creators/billy](https://n8n.io/creators/billy/)\n\ud83c\udf10 **My n8n Projects:** [billychristi.com/n8n](https://www.billychristi.com/n8n)  \n\n\n\n---\n\ud83d\udca1 Feel free to get in touch if you\u2019d like help on your next automation project or if you have any feedback or thoughts to share.\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Invoice Parser AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "PDF Text Extractor": {
      "main": [
        [
          {
            "node": "Invoice Parser AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Invoice PDF": {
      "main": [
        [
          {
            "node": "PDF Text Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Invoice Folder Monitor": {
      "main": [
        [
          {
            "node": "Download Invoice PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Invoice Parser AI Agent": {
      "main": [
        [
          {
            "node": "Insert Invoice Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Invoice Parser AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}