{
  "name": "Automated expense tracking with Telegram, easybits & Google Sheets",
  "nodes": [
    {
      "id": "040fbbb6-f170-483a-9ba8-476bfbbe10d0",
      "name": "Telegram Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1808,
        448
      ]
    },
    {
      "id": "27ee3948-7070-48ab-9357-104c0d82cbc0",
      "name": "Get File Info",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1360,
        352
      ]
    },
    {
      "id": "afea0a8f-e7a4-41fe-9bbd-12bacba09b38",
      "name": "Download Photo",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1136,
        352
      ]
    },
    {
      "id": "201f1b32-40a7-473d-85cf-be7167204fde",
      "name": "Convert to Base64",
      "type": "n8n-nodes-base.code",
      "position": [
        -912,
        352
      ]
    },
    {
      "id": "3258074d-7b36-4211-a241-56c814114f38",
      "name": "Extract with easybits",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -688,
        352
      ]
    },
    {
      "id": "4314ccd1-3b8a-4e7a-9637-da2cfa7460eb",
      "name": "Process Extraction",
      "type": "n8n-nodes-base.code",
      "position": [
        -464,
        352
      ]
    },
    {
      "id": "ec2f93d9-128c-4b26-84db-fd7575ce151e",
      "name": "Check Sheet Exists",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        304,
        208
      ]
    },
    {
      "id": "9cbcfda6-d34a-4b8c-bdfe-ed3233c3682b",
      "name": "Sheet Exists?",
      "type": "n8n-nodes-base.if",
      "position": [
        480,
        208
      ]
    },
    {
      "id": "e5c66f0a-d74a-464b-84ce-122c721e0bd8",
      "name": "Create Sheet",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        624,
        208
      ]
    },
    {
      "id": "7d6aeb48-6de4-4391-bb29-ad6ed31186bd",
      "name": "Setup Headers",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        960,
        208
      ]
    },
    {
      "id": "6c897a3c-4e65-4bf8-8cdc-c372fd008aef",
      "name": "Add Expense Row",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1344,
        416
      ]
    },
    {
      "id": "1012e563-289c-4839-ad1c-910eacfd19e1",
      "name": "Send Confirmation",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1984,
        416
      ]
    },
    {
      "id": "8799ca68-52c7-4719-a8a5-c9ed2ec7d815",
      "name": "No Photo Message",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1360,
        544
      ]
    },
    {
      "id": "3c286bd2-3993-4128-bb17-4b1c6ee9316a",
      "name": "Respond OK",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        2320,
        352
      ]
    },
    {
      "id": "afd5b5fc-ba86-454b-8429-a24a16a14d47",
      "name": "Respond OK 2",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        -1136,
        544
      ]
    },
    {
      "id": "760d18d6-5605-4345-9d5d-91a231dfba25",
      "name": "Build Headers Request",
      "type": "n8n-nodes-base.code",
      "position": [
        800,
        208
      ]
    },
    {
      "id": "43e43d79-146a-4a7c-be6e-04f7533d08e4",
      "name": "Build Expense Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1184,
        416
      ]
    },
    {
      "id": "1c2250d1-df50-45bb-be2e-21a3c4cd6dae",
      "name": "Build Row Format",
      "type": "n8n-nodes-base.code",
      "position": [
        1504,
        416
      ]
    },
    {
      "id": "5cc3b9c8-8a3b-4d5b-b7db-8a55326c9314",
      "name": "Format Data Row",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1680,
        400
      ]
    },
    {
      "id": "39dbf545-1897-4475-bb6a-f1a02bdd5f64",
      "name": "Get Sheet Info",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        624,
        416
      ]
    },
    {
      "id": "7497384a-6268-4a4d-b4af-87006bc2069d",
      "name": "Extract Sheet ID",
      "type": "n8n-nodes-base.code",
      "position": [
        800,
        416
      ]
    },
    {
      "id": "12f6d843-b3d5-4bd4-a0f3-74212f8d6ec7",
      "name": "Needs Category?",
      "type": "n8n-nodes-base.if",
      "position": [
        -240,
        352
      ]
    },
    {
      "id": "21f2b627-2894-4650-acf7-df320abbfa61",
      "name": "Ask for Category",
      "type": "n8n-nodes-base.telegram",
      "position": [
        0,
        352
      ]
    },
    {
      "id": "31759020-dac7-421a-8346-1f1346a2ff92",
      "name": "Has Photo or PDF?",
      "type": "n8n-nodes-base.if",
      "position": [
        -1584,
        448
      ]
    },
    {
      "id": "9a4d88c3-f8a1-4d2d-8ab1-d1a6f842de2b",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1856,
        352
      ],
      "parameters": {
        "width": 432,
        "height": 256,
        "content": "## 1. Receive input\nReceive receipt from Telegram. Check if message contains a photo or PDF."
      }
    },
    {
      "id": "31bb29ce-fc92-4af1-b36c-c410a6847306",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1392,
        240
      ],
      "parameters": {
        "width": 624,
        "height": 464,
        "content": "## 2. Download file\nDownload file from Telegram servers and convert to Base64 for easybits API."
      }
    },
    {
      "id": "8279c562-751c-4b3d-9838-f6866d6d6523",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -752,
        224
      ],
      "parameters": {
        "width": 448,
        "height": 288,
        "content": "## 3. Extract data\nSend file to easybits for extraction. Parse vendor, amount, date, and category."
      }
    },
    {
      "id": "4807ec76-f37b-41dc-a721-a6ce818342e8",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        224
      ],
      "parameters": {
        "width": 464,
        "height": 272,
        "content": "## 4. Handle unknown category\nIf category is \"Other\", ask user to resend with a caption specifying the category."
      }
    },
    {
      "id": "b6745c1d-82c5-41e9-a2d6-c1ee92f05050",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        112
      ],
      "parameters": {
        "width": 928,
        "height": 512,
        "content": "## 5. Prepare sheet\nCheck if monthly sheet exists. If not, create new sheet with headers and formatting."
      }
    },
    {
      "id": "f8428194-ed14-44f5-a892-362c98d819cc",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1152,
        112
      ],
      "parameters": {
        "width": 720,
        "height": 512,
        "content": "## 6. Add expense row\nAdd expense to the correct monthly sheet. Apply bold formatting to the data row."
      }
    },
    {
      "id": "850335ec-7b84-435e-9ed1-dba1eddb0ea1",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1888,
        112
      ],
      "parameters": {
        "width": 688,
        "height": 512,
        "content": "## 7. Confirm\nSend confirmation message to user with expense details."
      }
    },
    {
      "id": "d3264444-8027-4330-8a2b-fbefe8167b25",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2048,
        -656
      ],
      "parameters": {
        "width": 896,
        "height": 608,
        "content": "## Telegram Expense Bot\n\nAutomatically extract receipt data and organize expenses in Google Sheets.\n\n### How it works\n1. Send receipt photo or PDF to Telegram bot\n2. easybits extracts vendor, amount, "
      }
    }
  ],
  "connections": {
    "Create Sheet": {
      "main": [
        [
          {
            "node": "Build Headers Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get File Info": {
      "main": [
        [
          {
            "node": "Download Photo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Setup Headers": {
      "main": [
        [
          {
            "node": "Build Expense Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sheet Exists?": {
      "main": [
        [
          {
            "node": "Create Sheet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Sheet Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Photo": {
      "main": [
        [
          {
            "node": "Convert to Base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Sheet Info": {
      "main": [
        [
          {
            "node": "Extract Sheet ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Expense Row": {
      "main": [
        [
          {
            "node": "Build Row Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Data Row": {
      "main": [
        [
          {
            "node": "Send Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Needs Category?": {
      "main": [
        [
          {
            "node": "Ask for Category",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check Sheet Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ask for Category": {
      "main": [
        [
          {
            "node": "Respond OK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Row Format": {
      "main": [
        [
          {
            "node": "Format Data Row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Sheet ID": {
      "main": [
        [
          {
            "node": "Build Expense Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No Photo Message": {
      "main": [
        [
          {
            "node": "Respond OK 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Webhook": {
      "main": [
        [
          {
            "node": "Has Photo or PDF?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to Base64": {
      "main": [
        [
          {
            "node": "Extract with easybits",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Photo or PDF?": {
      "main": [
        [
          {
            "node": "Get File Info",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Photo Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Confirmation": {
      "main": [
        [
          {
            "node": "Respond OK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Expense Data": {
      "main": [
        [
          {
            "node": "Add Expense Row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Sheet Exists": {
      "main": [
        [
          {
            "node": "Sheet Exists?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Extraction": {
      "main": [
        [
          {
            "node": "Needs Category?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Headers Request": {
      "main": [
        [
          {
            "node": "Setup Headers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract with easybits": {
      "main": [
        [
          {
            "node": "Process Extraction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}