{
  "name": " Extract Details from Receipts via Telegram with Tesseract and Llama",
  "nodes": [
    {
      "id": "42a12e32-36e3-40c1-9f33-9947c0e263a1",
      "name": "Format Summary Message",
      "type": "n8n-nodes-base.code",
      "position": [
        120,
        200
      ]
    },
    {
      "id": "4078e97c-debf-4216-8c18-c9e1d8b76fd5",
      "name": "Get Telegram File",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -600,
        -180
      ]
    },
    {
      "id": "819b724d-7ab5-4a59-b3d0-52a77013c311",
      "name": "Download Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -300,
        -180
      ]
    },
    {
      "id": "9e7d33c8-42d1-4870-8626-087aae8375c6",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1280,
        0
      ]
    },
    {
      "id": "094293ee-dcdc-4a19-b33a-5361e12177db",
      "name": "Sticky - Telegram Trigger",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1280,
        -140
      ],
      "parameters": {
        "width": 260,
        "height": 180,
        "content": "## 📲 **Telegram Trigger**\nReceives user messages (text or photo) from Telegram to start the expense tracking flow."
      }
    },
    {
      "id": "49a51aa2-0a1c-417e-868e-d6a5f9284846",
      "name": "AI Categorizer",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -200,
        200
      ]
    },
    {
      "id": "15feb90d-e82f-4c45-8785-2fa9a26e98b7",
      "name": "Check Invalid Input",
      "type": "n8n-nodes-base.if",
      "position": [
        380,
        200
      ]
    },
    {
      "id": "cc4cf545-6ef9-455b-a5b6-9876bc2e3866",
      "name": "Extract Text Input",
      "type": "n8n-nodes-base.set",
      "position": [
        -600,
        200
      ]
    },
    {
      "id": "b6dc7831-994c-4539-a456-cbfde3c009a8",
      "name": "Check for Image",
      "type": "n8n-nodes-base.if",
      "position": [
        -980,
        0
      ]
    },
    {
      "id": "ea0c351f-8cae-4252-a3b9-34a1d03d3ef2",
      "name": "Sticky - Check for Image",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -980,
        -140
      ],
      "parameters": {
        "width": null,
        "height": 180,
        "content": "## 🔍 **Check for Image**\nDetermines whether the input is an image or text to route accordingly."
      }
    },
    {
      "id": "0e3d255e-69e7-4b78-82c4-1077a3ea91f4",
      "name": "Receipt Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -40,
        380
      ]
    },
    {
      "id": "675093cf-68b1-47b1-a2c5-aeda2e1b5360",
      "name": "AI Analyzer",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -200,
        380
      ]
    },
    {
      "id": "ffed21ef-2aed-4d63-b17e-df83bd4e6c9d",
      "name": "Send Error Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        700,
        180
      ]
    },
    {
      "id": "af0f7caa-f746-4eb3-bf57-4c345e448c23",
      "name": "Send Expense Summary",
      "type": "n8n-nodes-base.telegram",
      "position": [
        700,
        460
      ]
    },
    {
      "id": "9ebee364-9df5-4e05-acee-dad2e3f02d07",
      "name": "Sticky - Parse Receipt Data1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        680,
        -300
      ],
      "parameters": {
        "width": 360,
        "height": 200,
        "content": "## **MoneyMate is free to use!**\nGot feedback, ideas, or just wanna chat? Find me at [khmuhtadin.com](https://khmuhtadin.com).  \n\nWanna buy me a coffee to fuel more workflows? Head to [buymeacoffee.co"
      }
    },
    {
      "id": "13a31b33-3ccc-4680-a2c6-cd8255a827e0",
      "name": "Extract Value From Image",
      "type": "n8n-nodes-tesseractjs.tesseractNode",
      "position": [
        20,
        -180
      ]
    },
    {
      "id": "297c9837-890b-42a2-9234-3d808ada6850",
      "name": "Sticky - Send Expense Summary1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        700,
        360
      ],
      "parameters": {
        "width": 340,
        "height": null,
        "content": "## 📬 **Send Expense Summary**\nSends a summary of the recognized receipt or input to the user's Telegram chat."
      }
    },
    {
      "id": "32f7368a-cac0-4b4e-b944-9a3453a78118",
      "name": "Sticky - Extract Text Input1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        100
      ],
      "parameters": {
        "width": 260,
        "height": null,
        "content": "## 📝 **Extract Text Input**\nHandles plain text inputs when no image is provided by the user."
      }
    },
    {
      "id": "c7c9d1cd-368b-4374-9533-e3e76fb48c08",
      "name": "Sticky - Parse Receipt Data2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        500
      ],
      "parameters": {
        "width": 300,
        "height": null,
        "content": "## 📊 **Parse Receipt Data**\nConverts AI output into structured JSON with store, transaction, items, and totals."
      }
    },
    {
      "id": "4b3b0887-e3a7-4365-a41b-6773d2009d71",
      "name": "Sticky - Get Telegram File1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        -280
      ],
      "parameters": {
        "width": 260,
        "height": null,
        "content": "## 📦 **Get Telegram File**\nFetches the file ID of a receipt image uploaded via Telegram."
      }
    },
    {
      "id": "b1edb77f-6425-47f3-ba63-ed1b00dd6219",
      "name": "Sticky - Download Image2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -300,
        -280
      ],
      "parameters": {
        "width": 260,
        "height": null,
        "content": "## ⬇️ **Download Image**\nDownloads the receipt photo and prepares it for text extraction."
      }
    },
    {
      "id": "d7437f5c-276d-46b5-956b-72d89809ebc9",
      "name": "Sticky - Download Image3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -280
      ],
      "parameters": {
        "width": 260,
        "height": null,
        "content": "## 🖼️ **Text Extractor**\nExtract text from given image "
      }
    },
    {
      "id": "a381a022-9675-4e22-8bb5-b27992cfc3b8",
      "name": "Sticky - Format Summary Message1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        80
      ],
      "parameters": {
        "width": 260,
        "height": null,
        "content": "## 🧾 **Format Message**\nCreates a clear summary of expenses with store, date, items, total, and category."
      }
    },
    {
      "id": "5234e9fe-0202-460a-8a26-4dbf64ef3141",
      "name": "Sticky - AI Categorizer1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -200,
        80
      ],
      "parameters": {
        "width": 280,
        "height": null,
        "content": "## 🧠 **AI Categorizer**\nUses AI to classify input into categories like income or expenses, handling dates and languages."
      }
    },
    {
      "id": "1a7c3a49-a08c-4260-a393-04803a96aa02",
      "name": "Sticky - Send Error Message1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        700,
        80
      ],
      "parameters": {
        "width": 340,
        "height": null,
        "content": "## ❗ **Send Error Message**\nSends a warning to the user if the input is invalid or incomplete."
      }
    },
    {
      "id": "912961cb-4ce1-41ea-9007-876ad3478a09",
      "name": "Sticky - Check Invalid Input1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        80
      ],
      "parameters": {
        "width": 280,
        "height": null,
        "content": "## 🚫 **Check Invalid Input**\nDetects and flags incorrect or zero-value entries before sending a response."
      }
    },
    {
      "id": "56dfbcb7-b04c-41ba-b1e8-c7ad273a8bb4",
      "name": "Sticky - OpenRouter AI Model1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        500
      ],
      "parameters": {
        "width": 300,
        "height": null,
        "content": "## 🤖 **OpenRouter AI Model**\nConfigures the language model to extract structured information from natural language input."
      }
    }
  ],
  "connections": {
    "AI Analyzer": {
      "ai_languageModel": [
        [
          {
            "node": "AI Categorizer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Categorizer": {
      "main": [
        [
          {
            "node": "Format Summary Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Image": {
      "main": [
        [
          {
            "node": "Extract Value From Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receipt Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Categorizer",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Check for Image": {
      "main": [
        [
          {
            "node": "Get Telegram File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract Text Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Check for Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Telegram File": {
      "main": [
        [
          {
            "node": "Download Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text Input": {
      "main": [
        [
          {
            "node": "AI Categorizer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Invalid Input": {
      "main": [
        [
          {
            "node": "Send Error Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Expense Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Summary Message": {
      "main": [
        [
          {
            "node": "Check Invalid Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Value From Image": {
      "main": [
        [
          {
            "node": "AI Categorizer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}