{
  "name": "Automate purchase bill processing with AI OCR & QuickBooks integration",
  "nodes": [
    {
      "id": "303a50d1-5b14-42e0-9fef-8f50b9cb04df",
      "name": "Split Items to Create",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        4544,
        2032
      ]
    },
    {
      "id": "d4e09bce-aee2-4a4f-bbcf-4fe7d8c96f11",
      "name": "Create Items",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4768,
        2032
      ]
    },
    {
      "id": "2805b745-5725-460f-be2f-920bf4d444f4",
      "name": "Merge Item Creation Paths",
      "type": "n8n-nodes-base.merge",
      "position": [
        4992,
        2104
      ]
    },
    {
      "id": "b7827159-538e-464a-870f-fcc0af7afd67",
      "name": "Collect All Item Mappings",
      "type": "n8n-nodes-base.code",
      "position": [
        5216,
        2104
      ]
    },
    {
      "id": "965884c8-9a44-4e8a-9603-501d43d34b2f",
      "name": "Find Vendor",
      "type": "n8n-nodes-base.quickbooks",
      "position": [
        5440,
        2104
      ]
    },
    {
      "id": "a6548ed0-e56f-4c74-b9ea-d391122c855a",
      "name": "Vendor Exists?",
      "type": "n8n-nodes-base.if",
      "position": [
        5664,
        2104
      ]
    },
    {
      "id": "7eb10846-d37c-4b5b-a11e-d4392e2b77c2",
      "name": "Create Vendor",
      "type": "n8n-nodes-base.quickbooks",
      "position": [
        5904,
        2032
      ]
    },
    {
      "id": "e96e6a97-14b1-4269-a7cc-d3130a1a8a63",
      "name": "Create Bill ",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        6368,
        2144
      ]
    },
    {
      "id": "49f364de-8174-4e01-bf7b-d2be3286818a",
      "name": "Need to Create Items?",
      "type": "n8n-nodes-base.if",
      "position": [
        4320,
        2096
      ]
    },
    {
      "id": "6c671cc9-6009-484a-ae8a-67f2a7e90324",
      "name": "Get All QB Items",
      "type": "n8n-nodes-base.quickbooks",
      "position": [
        3872,
        2096
      ]
    },
    {
      "id": "84340514-dab8-4a14-b9ba-edc76ab396fd",
      "name": "Prepare Items to Check",
      "type": "n8n-nodes-base.code",
      "position": [
        3680,
        2096
      ]
    },
    {
      "id": "ed2369bb-2c7f-461f-aeb5-eed9391e4402",
      "name": "Extract Invoice Data",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        3296,
        2104
      ]
    },
    {
      "id": "ecf48035-31bc-43b8-8a2a-f4de560f134b",
      "name": "Clean Text",
      "type": "n8n-nodes-base.code",
      "position": [
        3056,
        2096
      ]
    },
    {
      "id": "3ee694dd-3899-4355-8687-d8bd83ad8bf8",
      "name": "Loop Over Invoices",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        2624,
        2228
      ]
    },
    {
      "id": "11125910-971f-4829-a010-d98ce0de67d8",
      "name": "Convert to Separate Items",
      "type": "n8n-nodes-base.code",
      "position": [
        2400,
        2228
      ]
    },
    {
      "id": "c123a41e-5799-4f30-876b-addff0693431",
      "name": "Extract from PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2848,
        2104
      ]
    },
    {
      "id": "5020b30e-b4ba-415d-b506-63db5368419c",
      "name": "Check Which Items to Create",
      "type": "n8n-nodes-base.code",
      "position": [
        4096,
        2096
      ]
    },
    {
      "id": "30ab1e9d-703f-4c78-8495-3399f8e793dd",
      "name": "Build Bill Payload",
      "type": "n8n-nodes-base.code",
      "position": [
        6144,
        2144
      ]
    },
    {
      "id": "6058dc16-7403-48c5-ad87-c27f9bde5138",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        3296,
        2400
      ]
    },
    {
      "id": "dd2fbbf5-ca57-4821-be26-3872991e6f0c",
      "name": "On bill submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        2176,
        2228
      ]
    },
    {
      "id": "77a10310-6a8c-4eba-a058-15e0af6d8b32",
      "name": "Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1696,
        2096
      ],
      "parameters": {
        "width": 420,
        "height": 400,
        "content": "## How it works\n1. **Upload**: Submit PDF invoices via web form\n2. **Extract**: AI reads invoice data (vendor, items, amounts, dates)\n3. **Reconcile**: Checks if items/vendors exist in QuickBooks\n4. *"
      }
    },
    {
      "id": "d3ec43fd-2232-4e5c-a537-39573a03d725",
      "name": "PDF Processing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2128,
        2096
      ],
      "parameters": {
        "width": 652,
        "height": 380,
        "content": "## PDF Processing\nConverts uploaded PDFs to separate items and loops through each invoice for extraction."
      }
    },
    {
      "id": "adde0363-ce66-413b-8448-ebcbadaeb596",
      "name": "AI Extraction",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3216,
        1952
      ],
      "parameters": {
        "width": 364,
        "height": 604,
        "content": "## AI Extraction\n\nExtracts structured data from invoice text using OpenRouter LLM (vendor, line items, dates, amounts)."
      }
    },
    {
      "id": "82616fc6-1e70-4c65-ac8d-b8b6f0beff8d",
      "name": "Item Management",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3600,
        1952
      ],
      "parameters": {
        "width": 1572,
        "height": 396,
        "content": "## Item Management\n\nChecks existing QuickBooks items against invoice line items. Creates missing items automatically with default accounts."
      }
    },
    {
      "id": "57243061-86f8-472b-a02a-df79f67370b3",
      "name": "Vendor Management",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5184,
        1952
      ],
      "parameters": {
        "width": 884,
        "height": 396,
        "content": "## Vendor Management\n\nSearches for vendor by name. Creates new vendor record if not found, using extracted contact info."
      }
    },
    {
      "id": "9ffda906-d1b5-4fc5-98ce-c2311d849e7f",
      "name": "Bill Creation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6080,
        1952
      ],
      "parameters": {
        "width": 440,
        "height": 396,
        "content": "## Bill Creation\n\nBuilds complete bill payload with all line items, vendor ref, dates, and tax. Posts to QuickBooks API."
      }
    }
  ],
  "connections": {
    "Clean Text": {
      "main": [
        [
          {
            "node": "Extract Invoice Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Vendor": {
      "main": [
        [
          {
            "node": "Vendor Exists?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Bill ": {
      "main": [
        [
          {
            "node": "Loop Over Invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Items": {
      "main": [
        [
          {
            "node": "Merge Item Creation Paths",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Vendor": {
      "main": [
        [
          {
            "node": "Build Bill Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Vendor Exists?": {
      "main": [
        [
          {
            "node": "Create Vendor",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build Bill Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from PDF": {
      "main": [
        [
          {
            "node": "Clean Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All QB Items": {
      "main": [
        [
          {
            "node": "Check Which Items to Create",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Bill Payload": {
      "main": [
        [
          {
            "node": "Create Bill ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Invoices": {
      "main": [
        [],
        [
          {
            "node": "Extract from PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On bill submission": {
      "main": [
        [
          {
            "node": "Convert to Separate Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Invoice Data": {
      "main": [
        [
          {
            "node": "Prepare Items to Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Need to Create Items?": {
      "main": [
        [
          {
            "node": "Split Items to Create",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge Item Creation Paths",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Extract Invoice Data",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Split Items to Create": {
      "main": [
        [
          {
            "node": "Create Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Items to Check": {
      "main": [
        [
          {
            "node": "Get All QB Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect All Item Mappings": {
      "main": [
        [
          {
            "node": "Find Vendor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to Separate Items": {
      "main": [
        [
          {
            "node": "Loop Over Invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Item Creation Paths": {
      "main": [
        [
          {
            "node": "Collect All Item Mappings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Which Items to Create": {
      "main": [
        [
          {
            "node": "Need to Create Items?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}