{
  "name": "Automate invoice data extraction with OCR.Space, GPT & Google Sheets",
  "nodes": [
    {
      "id": "c79d74f7-f2d7-4e35-891d-c428fcfc5dcc",
      "name": "Schedule Trigger (Weekly Scan)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        368,
        -416
      ]
    },
    {
      "id": "acb76a11-4ee8-468c-8023-a4f886f428c2",
      "name": "Get Parent Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        640,
        -416
      ]
    },
    {
      "id": "499da8a9-f455-4e8e-bf38-f3b5334ec442",
      "name": "Get Monthly Subfolder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        848,
        -416
      ]
    },
    {
      "id": "6c95fb12-8dcd-4df3-a611-d099c3298274",
      "name": "List Files",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1040,
        -416
      ]
    },
    {
      "id": "93009ba2-3af8-4ba0-9044-cf5fa15e0965",
      "name": "Download File (Binary from Drive)",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1232,
        -416
      ]
    },
    {
      "id": "b0761836-e013-4728-bb12-dc2e760cfa7f",
      "name": "OCR (OCR.Space Parsing)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1440,
        -416
      ]
    },
    {
      "id": "2f843a4c-82dd-45ae-8be8-b438d93fb8ea",
      "name": "Clean OCR Text (Noise Removal)",
      "type": "n8n-nodes-base.code",
      "position": [
        1680,
        -416
      ]
    },
    {
      "id": "888bed82-b755-4416-948c-4db664c1b371",
      "name": "AI Extraction (Generate Structured JSON)",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        304,
        -32
      ]
    },
    {
      "id": "2805e6a9-0304-4842-b5b6-eb4996b08dec",
      "name": "Parse AI Output to JSON",
      "type": "n8n-nodes-base.code",
      "position": [
        656,
        -32
      ]
    },
    {
      "id": "0d2e5f79-3c09-4352-af43-d7d895669991",
      "name": "Append to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        848,
        -32
      ]
    },
    {
      "id": "07e4ec6a-0526-44e6-a7ef-95b2d3e7cc22",
      "name": "Schedule Trigger (Recurring Execution)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        -640
      ],
      "parameters": {
        "width": 336,
        "height": 384,
        "content": "## Schedule Trigger (Recurring Execution)\nPurpose\n- Periodically scan the Drive folder that stores invoice PDFs.\n- Can also be executed manually for debugging."
      }
    },
    {
      "id": "7175d70d-bd7a-46c5-96c1-71691e215da5",
      "name": "Google Drive Folder Discovery",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        624,
        -640
      ],
      "parameters": {
        "width": 752,
        "height": 384,
        "content": "## Google Drive Folder Discovery\nPurpose\n- Get the parent folder (e.g., \"支払い請求書自動計算用フォルダ\" meaning \"Folder for automatic invoice calculation\").\n- Auto-detect the current-month subfolder (e.g., a folder"
      }
    },
    {
      "id": "7c0a7024-98f7-42f9-8937-4aced9dcbf7a",
      "name": "AI Extraction & Sheets Append",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        -224
      ],
      "parameters": {
        "width": 848,
        "height": 384,
        "content": "## AI Structured Extraction & Google Sheets Append\nPurpose\n- Convert OCR results to a strict JSON structure using GPT.\n- Extract invoice_date / due_date / client_name / subtotal / tax / total / bank_i"
      }
    },
    {
      "id": "bb521714-8b47-4a03-abc0-9e18a471021c",
      "name": "OCR Processing (PDF → Text Cleanup)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1392,
        -640
      ],
      "parameters": {
        "width": 400,
        "height": 384,
        "content": "## OCR Processing (PDF → Text Cleanup)\nPurpose\n- Download Drive files as binary.\n- Use the OCR.Space API for text extraction.\n- Remove noise and normalize line breaks."
      }
    }
  ],
  "connections": {
    "List Files": {
      "main": [
        [
          {
            "node": "Download File (Binary from Drive)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Parent Folder": {
      "main": [
        [
          {
            "node": "Get Monthly Subfolder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Monthly Subfolder": {
      "main": [
        [
          {
            "node": "List Files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OCR (OCR.Space Parsing)": {
      "main": [
        [
          {
            "node": "Clean OCR Text (Noise Removal)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Output to JSON": {
      "main": [
        [
          {
            "node": "Append to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean OCR Text (Noise Removal)": {
      "main": [
        [
          {
            "node": "AI Extraction (Generate Structured JSON)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger (Weekly Scan)": {
      "main": [
        [
          {
            "node": "Get Parent Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File (Binary from Drive)": {
      "main": [
        [
          {
            "node": "OCR (OCR.Space Parsing)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Extraction (Generate Structured JSON)": {
      "main": [
        [
          {
            "node": "Parse AI Output to JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}