{
  "name": "Log LINE invoice photos to Google Sheets with OCR.space and Gemini AI",
  "nodes": [
    {
      "id": "4884128d-48e0-4d8d-bd1d-0509757d36b8",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        2240,
        896
      ]
    },
    {
      "id": "332f9bf7-84c7-4357-a310-f23698b74598",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -32
      ],
      "parameters": {
        "width": 768,
        "height": 832,
        "content": "### How it works\n\nSend a photo of any invoice to the LINE bot and the rest is handled automatically. The workflow picks up the image via LINE Messaging API, pushes it through OCR.space to pull out the"
      }
    },
    {
      "id": "c0611d9c-86a6-4bee-bf92-66c59aaa4493",
      "name": "Receive LINE Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        832,
        864
      ]
    },
    {
      "id": "57aa751e-4673-45eb-85df-4aefc39eaee1",
      "name": "Return 200 OK to LINE",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1056,
        960
      ]
    },
    {
      "id": "0aaf96c2-2c3f-40af-a3c0-1c0a0e15fd00",
      "name": "Check Image Message",
      "type": "n8n-nodes-base.if",
      "position": [
        1280,
        768
      ]
    },
    {
      "id": "d150d722-c92f-4e49-9f73-5be948a35ba4",
      "name": "Variables (API Key Management)",
      "type": "n8n-nodes-base.set",
      "position": [
        1056,
        768
      ]
    },
    {
      "id": "ca1b9626-bb9b-411a-8703-7eb91145c44f",
      "name": "Fetch Image from LINE",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1504,
        672
      ]
    },
    {
      "id": "d690ddd9-c613-4194-8c26-af52d8392f81",
      "name": "Convert Image to Base64",
      "type": "n8n-nodes-base.code",
      "position": [
        1728,
        672
      ]
    },
    {
      "id": "9d8594dc-ac9d-4574-830c-1aee3bd68448",
      "name": "OCR - Extract Text from Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1952,
        672
      ]
    },
    {
      "id": "d26bc118-71ef-42fe-825f-41c31383320e",
      "name": "AI Agent - Parse Invoice with Gemini",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2176,
        672
      ]
    },
    {
      "id": "7131ca36-708d-46b4-aa66-1eed8d37d9fa",
      "name": "Parse & Format JSON",
      "type": "n8n-nodes-base.code",
      "position": [
        2528,
        672
      ]
    },
    {
      "id": "5c0906e4-e89a-4f24-88dd-685c5979b9b5",
      "name": "Error Check",
      "type": "n8n-nodes-base.if",
      "position": [
        2752,
        672
      ]
    },
    {
      "id": "e8db1063-2a25-430b-ae0c-719c099305d1",
      "name": "Append to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2976,
        576
      ]
    },
    {
      "id": "36693043-1824-4036-a0e1-b60090ce52df",
      "name": "LINE Reply - Success",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3200,
        576
      ]
    },
    {
      "id": "843acd2b-4e64-425b-8da8-244653ab8ee4",
      "name": "LINE Reply - Error",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2976,
        768
      ]
    },
    {
      "id": "d53f474d-f3bc-4740-bace-8ae5233ef30b",
      "name": "LINE Reply - Not an Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1504,
        864
      ]
    },
    {
      "id": "c16b8ff5-a39a-4813-b47e-6fe404d3c2cb",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1008,
        432
      ],
      "parameters": {
        "width": 288,
        "height": 208,
        "content": "## Image Intake\nReceives the invoice image from LINE via Webhook, filters for image messages only, and downloads the file for processing."
      }
    },
    {
      "id": "7b856104-c72c-433a-9f91-0b826824465c",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1792,
        448
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": "## Text Extraction\nConverts the image to Base64 and sends it to OCR.space, which returns the raw text content of the invoice."
      }
    },
    {
      "id": "c0ee045b-f368-4c81-a772-ceb84fa0f0a2",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2160,
        416
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": "## AI Parsing\nGemini AI reads the raw OCR text and structures it into labelled invoice fields, returned as clean JSON."
      }
    },
    {
      "id": "de76afc5-39da-4b36-a286-002971cc4ad6",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2896,
        352
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": "## Log & Notify\nAppends the parsed invoice data to Google Sheets and sends a success confirmation back to the user on LINE."
      }
    },
    {
      "id": "aaf9abf1-ece5-42ff-a2fd-d93afc1a8cb8",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2576,
        384
      ],
      "parameters": {
        "width": 288,
        "height": 208,
        "content": "## Error Handling\nChecks whether the AI successfully parsed the invoice and routes to the appropriate success or error reply."
      }
    },
    {
      "id": "83ee455c-434a-4cd6-97f1-f694389f3cc1",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3152,
        352
      ],
      "parameters": {
        "width": 288,
        "height": 208,
        "content": "## LINE Reply\nSends a success message or a clear error message back to the user depending on the parsing result."
      }
    }
  ],
  "connections": {
    "Error Check": {
      "main": [
        [
          {
            "node": "Append to Google Sheets",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "LINE Reply - Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Image Message": {
      "main": [
        [
          {
            "node": "Fetch Image from LINE",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "LINE Reply - Not an Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse & Format JSON": {
      "main": [
        [
          {
            "node": "Error Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive LINE Webhook": {
      "main": [
        [
          {
            "node": "Return 200 OK to LINE",
            "type": "main",
            "index": 0
          },
          {
            "node": "Variables (API Key Management)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Image from LINE": {
      "main": [
        [
          {
            "node": "Convert Image to Base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append to Google Sheets": {
      "main": [
        [
          {
            "node": "LINE Reply - Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Image to Base64": {
      "main": [
        [
          {
            "node": "OCR - Extract Text from Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent - Parse Invoice with Gemini",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OCR - Extract Text from Image": {
      "main": [
        [
          {
            "node": "AI Agent - Parse Invoice with Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Variables (API Key Management)": {
      "main": [
        [
          {
            "node": "Check Image Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent - Parse Invoice with Gemini": {
      "main": [
        [
          {
            "node": "Parse & Format JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}