{
  "name": "Extract Indonesian stock (IDX) trades from Telegram invoices with Gemini AI",
  "nodes": [
    {
      "id": "fbb15b1c-2856-480e-b324-1bda0624c0a3",
      "name": "Sticky Note - Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        352
      ],
      "parameters": {
        "width": 460,
        "height": 724,
        "content": "## 🇮🇩 Indonesian Stock (IDX) Invoice Reader\n\nAutomatically extract stock transactions from Indonesian broker trade confirmations sent via Telegram.\n\n### How it works\n1. Send a broker PDF or image to y"
      }
    },
    {
      "id": "2ce04cd4-03ed-4d90-97f4-c40460b2e9d1",
      "name": "Sticky Note - Message Intake",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        112,
        400
      ],
      "parameters": {
        "width": 680,
        "height": 320,
        "content": "## 📨 Message Intake\nReceives all Telegram updates (messages and button callbacks), parses the incoming data, and routes file uploads to the processing branch."
      }
    },
    {
      "id": "d200c299-1aca-4de9-b1ac-358629c16d36",
      "name": "Sticky Note - File Processing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        768
      ],
      "parameters": {
        "width": 660,
        "height": 304,
        "content": "## 📁 File Processing\nDownloads the file from Telegram servers, reads the binary data, and encodes it as base64 ready for the AI request."
      }
    },
    {
      "id": "d8110936-d046-41fc-bb9c-9e0c7e13b594",
      "name": "Sticky Note - AI Extraction",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1344,
        416
      ],
      "parameters": {
        "width": 660,
        "height": 304,
        "content": "## 🤖 AI Extraction\nBuilds the OpenRouter request (PDF or image format), calls Gemini, and parses the JSON array of transactions from the response."
      }
    },
    {
      "id": "064977ba-9df1-417d-b95d-b6b1a6bd81f4",
      "name": "Sticky Note - Confirmation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2048,
        768
      ],
      "parameters": {
        "width": 660,
        "height": 476,
        "content": "## ✅ Confirmation\nGroups all extracted transactions into a batch, stores them temporarily in workflow static data, and sends a confirmation message with Save All / Cancel buttons."
      }
    },
    {
      "id": "e5b0a373-003c-4cb8-90b4-d58eaf3b66f0",
      "name": "Route Type1",
      "type": "n8n-nodes-base.switch",
      "position": [
        592,
        544
      ]
    },
    {
      "id": "387a2288-194f-43eb-80a4-461ffe675758",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        176,
        560
      ]
    },
    {
      "id": "abdc6eac-5b1b-44f1-8da9-5a78eb56a5fc",
      "name": "Parse Message",
      "type": "n8n-nodes-base.code",
      "position": [
        384,
        560
      ]
    },
    {
      "id": "f48db73a-00ea-42f4-80b9-09e6fddbea52",
      "name": "Extract File Info",
      "type": "n8n-nodes-base.code",
      "position": [
        832,
        928
      ]
    },
    {
      "id": "ed99dc61-6ff0-4d91-92a5-4c2747906d7e",
      "name": "Download File",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1024,
        928
      ]
    },
    {
      "id": "0c36dfa0-859a-4fc6-a5ed-3a9004402752",
      "name": "Prepare File",
      "type": "n8n-nodes-base.code",
      "position": [
        1232,
        928
      ]
    },
    {
      "id": "a8e8d7f4-aa6b-4809-9c2c-0b46a3572134",
      "name": "Build Request",
      "type": "n8n-nodes-base.code",
      "position": [
        1392,
        560
      ]
    },
    {
      "id": "9e925f68-de8f-43b0-87b4-2fa26ee6fea3",
      "name": "OpenRouter Extract",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1616,
        560
      ]
    },
    {
      "id": "0b0040e2-0827-44ad-947e-da4717ddf159",
      "name": "Parse Invoice",
      "type": "n8n-nodes-base.code",
      "position": [
        1824,
        560
      ]
    },
    {
      "id": "8f1b3f27-178c-475f-9878-5b4aaf0a48a1",
      "name": "Invoice Error?",
      "type": "n8n-nodes-base.if",
      "position": [
        2096,
        992
      ]
    },
    {
      "id": "04cd428b-e315-4d3a-91e0-3097e5c956e9",
      "name": "Format Confirmation",
      "type": "n8n-nodes-base.code",
      "position": [
        2320,
        896
      ]
    },
    {
      "id": "b951be47-0a1d-4efc-b396-1906b9383a87",
      "name": "Send Confirmation",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2560,
        896
      ]
    },
    {
      "id": "1a01e12b-4e49-4ccf-abcd-e56bbc892059",
      "name": "Reply Invoice Error",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2336,
        1088
      ]
    }
  ],
  "connections": {
    "Route Type1": {
      "main": [
        [],
        [
          {
            "node": "Extract File Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare File": {
      "main": [
        [
          {
            "node": "Build Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Request": {
      "main": [
        [
          {
            "node": "OpenRouter Extract",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Prepare File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Invoice": {
      "main": [
        [
          {
            "node": "Invoice Error?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Message": {
      "main": [
        [
          {
            "node": "Route Type1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Invoice Error?": {
      "main": [
        [
          {
            "node": "Reply Invoice Error",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Format Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Parse Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract File Info": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Extract": {
      "main": [
        [
          {
            "node": "Parse Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Confirmation": {
      "main": [
        [
          {
            "node": "Send Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}