{
  "name": "Invoice processor & validator with OCR, AI & Google Sheets",
  "nodes": [
    {
      "id": "0d426dc6-d9ff-44cd-82f0-9d87bda8821a",
      "name": "When clicking ‘Test workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -200,
        405
      ]
    },
    {
      "id": "2722d720-22e9-488b-9b39-4273fe88257c",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        548,
        625
      ]
    },
    {
      "id": "6992dfda-d65e-4694-8261-2328a7d0bc09",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1276,
        280
      ]
    },
    {
      "id": "06e91f54-fbc3-4161-949c-779ecd7924b9",
      "name": "Post-Processing",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        380
      ]
    },
    {
      "id": "34f5988b-9c83-4828-a13d-1ff33615e509",
      "name": "Text Extractor",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        460,
        420
      ]
    },
    {
      "id": "3446d02e-2c94-4575-9062-455dbd71ecd8",
      "name": "Read/Write Files from Disk",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        20,
        405
      ]
    },
    {
      "id": "95e99fb0-a12f-40e6-9126-d84cf2b0c493",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        240,
        405
      ]
    },
    {
      "id": "ce0a9035-c99f-4cc3-9ec3-b2be2158623e",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        1100,
        340
      ]
    },
    {
      "id": "6675d752-7230-4335-9c68-387396728e7f",
      "name": "Send Raw Text Again",
      "type": "n8n-nodes-base.set",
      "position": [
        1340,
        520
      ]
    },
    {
      "id": "7706b71b-25dc-4f61-b975-51322d7b9d32",
      "name": "Validation",
      "type": "n8n-nodes-base.code",
      "position": [
        2156,
        280
      ]
    },
    {
      "id": "34e482d2-9658-496b-ad2f-fc376f3490ff",
      "name": "Send Invoice Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1716,
        280
      ]
    },
    {
      "id": "3e30f4f1-15e1-41d9-a7f3-bf49d6273c02",
      "name": "Fetch Master Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1980,
        280
      ]
    },
    {
      "id": "7a46cfd3-3e2f-4818-80cd-e2776d0303a5",
      "name": "Update Results",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2460,
        280
      ]
    },
    {
      "id": "d9752205-2712-46d0-9058-86857f28e470",
      "name": "Generate Unique Key",
      "type": "n8n-nodes-base.set",
      "position": [
        1496,
        280
      ]
    },
    {
      "id": "52a2b54a-69e8-4a83-9861-5931a51a7162",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        320
      ],
      "parameters": {
        "width": 620,
        "height": 280,
        "content": "## Reading Invoice's PDF File Locally"
      }
    },
    {
      "id": "67d04fa9-3ad7-4613-89f0-511f9ee32f1d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        320
      ],
      "parameters": {
        "width": 380,
        "height": 280,
        "content": "## Extracting Details From Invoice PDF"
      }
    },
    {
      "id": "4465dff2-ea51-4392-8aa7-8a780a73c33e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        320
      ],
      "parameters": {
        "width": null,
        "height": 220,
        "content": "## Processing Output"
      }
    },
    {
      "id": "c4ed886e-3e16-451b-b554-badb5f130623",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1280,
        460
      ],
      "parameters": {
        "width": 220,
        "height": 220,
        "content": "## Fallback On Error"
      }
    },
    {
      "id": "159dd4d1-f052-4401-a426-0621af19d300",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1240,
        220
      ],
      "parameters": {
        "width": 400,
        "height": 220,
        "content": "## Extracting Line Items"
      }
    },
    {
      "id": "b90a3aba-a18a-4846-a22d-cbd72aac8e6d",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1660,
        200
      ],
      "parameters": {
        "width": 220,
        "height": 240,
        "content": "## Sending Data To G-Sheet"
      }
    },
    {
      "id": "69e4f146-394f-4dc2-ab70-22337a3031e9",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1900,
        200
      ],
      "parameters": {
        "width": 440,
        "height": 240,
        "content": "## Fetch Master Data & Validating Invoice Extracted Data"
      }
    },
    {
      "id": "23c130e3-1727-48a2-b050-a4fdc07749f1",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2360,
        200
      ],
      "parameters": {
        "width": 300,
        "height": 240,
        "content": "## Update Validation Result"
      }
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Send Raw Text Again",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Generate Unique Key",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validation": {
      "main": [
        [
          {
            "node": "Update Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text Extractor": {
      "main": [
        [
          {
            "node": "Post-Processing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post-Processing": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Text Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Master Data": {
      "main": [
        [
          {
            "node": "Validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Invoice Data": {
      "main": [
        [
          {
            "node": "Fetch Master Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Unique Key": {
      "main": [
        [
          {
            "node": "Send Invoice Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Raw Text Again": {
      "main": [
        [
          {
            "node": "Text Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Text Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Read/Write Files from Disk": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Read/Write Files from Disk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}