{
  "name": "Invoice verification and validation with Gmail, Drive, Sheets and OCR AI",
  "nodes": [
    {
      "id": "1d22cbef-a424-4c22-9365-9b5925de2dd5",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -1240,
        320
      ]
    },
    {
      "id": "5ed93d14-2ccf-4608-af7e-0de45c8a8b4f",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -800,
        300
      ]
    },
    {
      "id": "801a89a2-1033-46ce-a514-da48581ad7aa",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        20,
        0
      ]
    },
    {
      "id": "13284bb7-9e59-42b8-ac39-d1a0a3694a5a",
      "name": "Post-Processing",
      "type": "n8n-nodes-base.code",
      "position": [
        -380,
        60
      ]
    },
    {
      "id": "e7e86334-ac7b-43d0-b518-68111c358ad6",
      "name": "Text Extractor",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -820,
        140
      ]
    },
    {
      "id": "320d2a1f-92b3-46b7-ae9e-6b025c50393e",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        -200,
        60
      ]
    },
    {
      "id": "14320290-f059-4e23-a9b3-dac08dee0038",
      "name": "Send Raw Text Again",
      "type": "n8n-nodes-base.set",
      "position": [
        0,
        240
      ]
    },
    {
      "id": "a482f4f6-02c5-4dc5-8101-355e44870a14",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1000,
        260
      ]
    },
    {
      "id": "2b8174d9-6ea3-4b54-a556-856b8bf2ce01",
      "name": "Send Invoice Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        480,
        0
      ]
    },
    {
      "id": "de512a48-39b7-49f8-a149-c50a188f3067",
      "name": "Fetch Master Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        680,
        0
      ]
    },
    {
      "id": "9edf61a4-5675-4497-9101-a3971f643f7c",
      "name": "Update Results",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1120,
        0
      ]
    },
    {
      "id": "3afe5d8b-71a1-4678-a84a-038820b172ae",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        1760,
        260
      ]
    },
    {
      "id": "cd7afab5-1834-44d0-b7d7-8be7ca6e927d",
      "name": "Update Totals",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1540,
        0
      ]
    },
    {
      "id": "aee40f65-662f-468f-b78b-d21a7ba1e35e",
      "name": "Get last Index",
      "type": "n8n-nodes-base.code",
      "position": [
        1320,
        0
      ]
    },
    {
      "id": "eaccc050-0cb9-4c0a-b51c-a65519543e28",
      "name": "Generate Unique Key",
      "type": "n8n-nodes-base.set",
      "position": [
        220,
        0
      ]
    },
    {
      "id": "52b6e590-13aa-43de-b926-73ba35119749",
      "name": "Validation",
      "type": "n8n-nodes-base.code",
      "position": [
        940,
        0
      ]
    },
    {
      "id": "d16d5797-7edb-4a8a-bd87-37318a262635",
      "name": "Upload Invoices",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -1240,
        60
      ]
    },
    {
      "id": "7ff71799-9511-420f-8e5d-d2bedee65435",
      "name": "Get Attachments",
      "type": "n8n-nodes-base.code",
      "position": [
        -1480,
        160
      ]
    },
    {
      "id": "08a26b26-40a6-40a3-9b24-d4213c5ac99d",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        -1700,
        160
      ]
    },
    {
      "id": "4b04705c-41bd-4e72-b82b-e45ed81ed421",
      "name": "Create Month Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -3020,
        180
      ]
    },
    {
      "id": "57fe45ba-46d0-4523-9898-98e1c4d06771",
      "name": "Create Day Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -2140,
        160
      ]
    },
    {
      "id": "c345741a-4b01-4c59-98ff-4d671e0ee6b2",
      "name": "Search Month Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -3440,
        180
      ]
    },
    {
      "id": "64fecc15-e87b-41f0-ad3d-7c9aae9089f6",
      "name": "Month Folder Found?",
      "type": "n8n-nodes-base.if",
      "position": [
        -3240,
        180
      ]
    },
    {
      "id": "d1ff1737-5edb-4c48-95a1-31a3b6158658",
      "name": "Search Day Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -2800,
        180
      ]
    },
    {
      "id": "7a119c08-83f3-4cfa-b5af-6a2c6eb96db2",
      "name": "Day Folder Found?",
      "type": "n8n-nodes-base.if",
      "position": [
        -2580,
        180
      ]
    },
    {
      "id": "ed86ba5d-6c46-4c9e-bfdc-c3f3a0ff1bb2",
      "name": "Get Parent Folder ID",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -2360,
        160
      ]
    },
    {
      "id": "9299234c-fbe3-4b8d-a4f1-c2be9e3e8475",
      "name": "Get Day Folder ID",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -1920,
        160
      ]
    },
    {
      "id": "d06008eb-b173-41b6-8750-01482ae99978",
      "name": "Today's Date",
      "type": "n8n-nodes-base.code",
      "position": [
        -4340,
        260
      ]
    },
    {
      "id": "a0c8c338-0db6-4136-8ec6-61be5026a071",
      "name": "Date & Time",
      "type": "n8n-nodes-base.dateTime",
      "position": [
        -4560,
        260
      ]
    },
    {
      "id": "cb7c60c4-7754-4a58-a93f-8c7e38910317",
      "name": "Read Message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -3680,
        180
      ]
    },
    {
      "id": "42702132-3f06-4013-912e-8e203e751a4f",
      "name": "Date From Email Subject",
      "type": "n8n-nodes-base.code",
      "position": [
        -3900,
        180
      ]
    },
    {
      "id": "f462ff4f-d8e5-4055-b154-b27da3c05810",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4780,
        160
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "fb3658be-c114-45e3-8277-265fca27bdf7",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -4100,
        260
      ]
    },
    {
      "id": "d5f01e22-2920-4763-ad33-cf5af192ef8e",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -4720,
        260
      ]
    },
    {
      "id": "cb99d7e4-2f71-4553-8636-5cb29b9f5ba7",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4140,
        120
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "3577a2e3-5c6b-4871-bf50-568eda532e71",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3480,
        120
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "aede2ed7-98c0-4f4c-853f-adfb6c7c7379",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2820,
        120
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "02652793-e97c-4125-af9e-9dcdc115adc1",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1960,
        100
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "55392a23-4ee8-404e-b316-4f693a28679c",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1300,
        0
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "d908e128-4ce2-433c-8d07-7a45a43f9d66",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1300,
        260
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "79afcd7b-c925-418a-a076-1186a6f5f95e",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        60
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "4a071404-9e78-4d11-baee-ef19b9b91323",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        0
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "e1a063cc-b1cf-492e-b395-b051786bde66",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -20,
        -60
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "a3d4be55-4ff6-413f-9b83-d22d7fa7e946",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        -80
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "f9d7132f-c9a3-49f6-9a7b-c7a6851bbb06",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        -80
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "e7e7b9e0-3fdf-45e3-9ae1-4979ba55a028",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1300,
        -80
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "ee01bd07-ab06-4ab2-812d-f0ea1fb77c72",
      "name": "Notify",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -980,
        -120
      ]
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Send Raw Text Again",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Get Attachments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Generate Unique Key",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validation": {
      "main": [
        [
          {
            "node": "Update Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time": {
      "main": [
        [
          {
            "node": "Today's Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Message": {
      "main": [
        [
          {
            "node": "Search Month Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Today's Date": {
      "main": [
        [
          {
            "node": "Gmail Trigger",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Date From Email Subject",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Update Totals": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get last Index": {
      "main": [
        [
          {
            "node": "Update Totals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text Extractor": {
      "main": [
        [
          {
            "node": "Post-Processing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Results": {
      "main": [
        [
          {
            "node": "Get last Index",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Attachments": {
      "main": [
        [
          {
            "node": "Upload Invoices",
            "type": "main",
            "index": 0
          },
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Notify",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Text Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post-Processing": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Date & Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Day Folder": {
      "main": [
        [
          {
            "node": "Get Day Folder ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Day Folder Found?": {
      "main": [
        [
          {
            "node": "Get Parent Folder ID",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Day Folder ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Master Data": {
      "main": [
        [
          {
            "node": "Validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Day Folder ID": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Day Folder": {
      "main": [
        [
          {
            "node": "Day Folder Found?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Invoice Data": {
      "main": [
        [
          {
            "node": "Fetch Master Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Month Folder": {
      "main": [
        [
          {
            "node": "Search Day Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Unique Key": {
      "main": [
        [
          {
            "node": "Send Invoice Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Month Folder Found?": {
      "main": [
        [
          {
            "node": "Create Month Folder",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Search Day Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Month Folder": {
      "main": [
        [
          {
            "node": "Month Folder Found?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Raw Text Again": {
      "main": [
        [
          {
            "node": "Text Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Parent Folder ID": {
      "main": [
        [
          {
            "node": "Create Day Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Text Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Date From Email Subject": {
      "main": [
        [
          {
            "node": "Read Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}