{
  "name": "Extract invoice data from scanned PDFs to Google Sheets with Sarvam and Gemini",
  "nodes": [
    {
      "id": "1d8aaea5-50f4-417c-a495-10bbead06c7e",
      "name": "Get OCR Result",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4736,
        512
      ]
    },
    {
      "id": "2f3e09a9-4c89-4d92-9974-d311bd98764c",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        4512,
        528
      ]
    },
    {
      "id": "c9f9cbda-9b96-4ae6-a07c-989a50a24ee3",
      "name": "Information Extractor",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        6016,
        416
      ]
    },
    {
      "id": "17cc69a7-89a4-4878-85ba-c3fa474fcced",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        6112,
        560
      ]
    },
    {
      "id": "94386d1a-d6d0-4310-8b0b-ffe11c9dea44",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2320,
        16
      ],
      "parameters": {
        "width": 488,
        "height": 268,
        "content": "![Sarvam](https://i.ibb.co/cqhn57z/Image-25-02-26-at-4-57-PM.png)"
      }
    },
    {
      "id": "e62143ab-fbdc-450a-87cb-4290101a7de1",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2320,
        304
      ],
      "parameters": {
        "width": 476,
        "height": 960,
        "content": "## Try It Out!\n### This template is designed for operations, finance, and accounting teams that need to automatically process scanned invoices and extract structured data without manual entry.\n\nIt is "
      }
    },
    {
      "id": "c231d31a-63f6-45cd-b315-3ad3a5eb66da",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2880,
        288
      ],
      "parameters": {
        "width": 680,
        "height": 396,
        "content": "## Step 1 – Upload invoice to Sarvam\n\nCreates an OCR job and uploads the invoice PDF to Sarvam Vision using a presigned URL."
      }
    },
    {
      "id": "2600dbea-343e-43b0-915a-b80754561431",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3968,
        288
      ],
      "parameters": {
        "width": 680,
        "height": 396,
        "content": "## Step 2 – Run OCR and monitor status\n\nStarts invoice OCR processing and polls the job status until processing is complete."
      }
    },
    {
      "id": "93779407-170e-4777-829b-d8c216597ea8",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4864,
        272
      ],
      "parameters": {
        "width": 680,
        "height": 396,
        "content": "## Step 3 – Retrieve OCR output\n\nDownloads the processed invoice output, decompresses the file, and extracts structured OCR JSON."
      }
    },
    {
      "id": "64f63c6a-1b4b-4b12-8dc5-291278ba49a1",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5616,
        272
      ],
      "parameters": {
        "width": 680,
        "height": 396,
        "content": "## Step 4 – Convert OCR text to structured invoice fields\n\nCleans OCR text and uses an LLM to extract structured invoice data such as vendor name, invoice number, date, and total amount."
      }
    },
    {
      "id": "5bf723ac-5039-49a1-aac2-845cb51f38a3",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6368,
        272
      ],
      "parameters": {
        "width": 568,
        "height": 396,
        "content": "## Step 5 – Store invoice data\n\nAppends extracted invoice fields to Google Sheets for accounting and tracking."
      }
    },
    {
      "id": "77ff9c34-271c-40ce-9073-09f69e34af8a",
      "name": "Trigger – Invoice upload (PDF)",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        2944,
        512
      ]
    },
    {
      "id": "031609ee-fac3-4ec3-a5f0-e42a68b606c1",
      "name": "Create Sarvam invoice OCR job",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3168,
        448
      ]
    },
    {
      "id": "03b6619c-b0bb-4bfa-8263-71bea0e78ddb",
      "name": "Generate Sarvam presigned upload URL",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3392,
        448
      ]
    },
    {
      "id": "fbba4b7c-b87f-4b44-b0c4-4e5386004928",
      "name": "Merge job details with upload URL",
      "type": "n8n-nodes-base.merge",
      "position": [
        3648,
        528
      ]
    },
    {
      "id": "47311e83-af0a-4eaa-bd4c-60e98b5e0321",
      "name": "Upload invoice PDF to Sarvam",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3840,
        528
      ]
    },
    {
      "id": "0adf4930-6472-4609-a634-1ad4f03fd7ed",
      "name": "Start Sarvam invoice OCR",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4064,
        528
      ]
    },
    {
      "id": "f5ea5e03-d459-4726-b3d0-7b24207233f4",
      "name": "Check Sarvam OCR status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4288,
        528
      ]
    },
    {
      "id": "54d04f7f-d3b4-4c15-a601-23949597a9db",
      "name": "Download Sarvam OCR output ZIP",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4960,
        512
      ]
    },
    {
      "id": "f358f256-8000-4c7a-b9b9-9e7a4196a44a",
      "name": "Decompress OCR result file",
      "type": "n8n-nodes-base.compression",
      "position": [
        5184,
        512
      ]
    },
    {
      "id": "9217f6b2-3398-4db6-b289-a1159468a3ca",
      "name": "Extract invoice OCR JSON",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        5408,
        512
      ]
    },
    {
      "id": "65054226-a6c5-4a94-ae25-ba4d387aa369",
      "name": "Prepare invoice text for LLM",
      "type": "n8n-nodes-base.code",
      "position": [
        5792,
        416
      ]
    },
    {
      "id": "68d1eb26-eb97-498f-8e0d-69f56e9dcf12",
      "name": "Append extracted invoice data to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        6544,
        416
      ]
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Get OCR Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get OCR Result": {
      "main": [
        [
          {
            "node": "Download Sarvam OCR output ZIP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Information Extractor": {
      "main": [
        [
          {
            "node": "Append extracted invoice data to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Sarvam OCR status": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract invoice OCR JSON": {
      "main": [
        [
          {
            "node": "Prepare invoice text for LLM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Information Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Start Sarvam invoice OCR": {
      "main": [
        [
          {
            "node": "Check Sarvam OCR status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Decompress OCR result file": {
      "main": [
        [
          {
            "node": "Extract invoice OCR JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare invoice text for LLM": {
      "main": [
        [
          {
            "node": "Information Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload invoice PDF to Sarvam": {
      "main": [
        [
          {
            "node": "Start Sarvam invoice OCR",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Sarvam invoice OCR job": {
      "main": [
        [
          {
            "node": "Generate Sarvam presigned upload URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Sarvam OCR output ZIP": {
      "main": [
        [
          {
            "node": "Decompress OCR result file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger – Invoice upload (PDF)": {
      "main": [
        [
          {
            "node": "Create Sarvam invoice OCR job",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge job details with upload URL",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge job details with upload URL": {
      "main": [
        [
          {
            "node": "Upload invoice PDF to Sarvam",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Sarvam presigned upload URL": {
      "main": [
        [
          {
            "node": "Merge job details with upload URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}