{
  "name": "Automate income and expense tracking in Google Sheets via Telegram",
  "nodes": [
    {
      "id": "326fd72f-6856-47f8-a033-7adbb2eea738",
      "name": "Telegram - Incoming Webhook",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -100,
        200
      ]
    },
    {
      "id": "f8d79eab-fbcd-46e2-822d-b64f6cdf2343",
      "name": "Detect Message Type",
      "type": "n8n-nodes-base.code",
      "position": [
        80,
        200
      ]
    },
    {
      "id": "cd68fd6e-653a-4cd1-92a4-ebcc7821c36e",
      "name": "Route by Input Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        260,
        200
      ]
    },
    {
      "id": "4e054ecd-82dc-4e39-97f1-5bc2eb3e2e40",
      "name": "Handle /start or Message Input",
      "type": "n8n-nodes-base.switch",
      "position": [
        480,
        0
      ]
    },
    {
      "id": "35faafd8-42c9-44cb-8612-deaa5270f186",
      "name": "Show Income/Expense Options",
      "type": "n8n-nodes-base.telegram",
      "position": [
        700,
        -160
      ]
    },
    {
      "id": "83d3e6b4-c30c-418b-bc09-53876fd047a3",
      "name": "Validate Input Format",
      "type": "n8n-nodes-base.code",
      "position": [
        700,
        20
      ]
    },
    {
      "id": "8bfb1fac-30ce-4c3a-b7af-2c8ffe6fb259",
      "name": "Extract Data Type",
      "type": "n8n-nodes-base.code",
      "position": [
        940,
        20
      ]
    },
    {
      "id": "50185b94-d3ce-4c5b-b88a-eb48712abc1b",
      "name": "Route Based on Data Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        1140,
        20
      ]
    },
    {
      "id": "dfa8ee96-8dee-4cf6-b14d-58aad6fb2c66",
      "name": "Parse Income Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1340,
        -100
      ]
    },
    {
      "id": "ba76cb99-365d-4b49-8935-ca44a17662b6",
      "name": "Save Income to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1540,
        -100
      ]
    },
    {
      "id": "ea50a3b1-40ff-48d3-940c-badc9c474526",
      "name": "Notify User Income Recorded",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1740,
        -100
      ]
    },
    {
      "id": "9d8399a5-f689-4589-b5ab-2b5735613a12",
      "name": "Parse Expense Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1340,
        40
      ]
    },
    {
      "id": "73831130-fb6a-4040-8857-b256203b8502",
      "name": "Save Expense to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1540,
        40
      ]
    },
    {
      "id": "fa0c19ae-f044-4533-b885-9ddc26522344",
      "name": "Notify User Expense Pending",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1740,
        40
      ]
    },
    {
      "id": "f06a85ad-5f76-485c-94cf-8465aae0ea50",
      "name": "Send Approval Request",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1920,
        40
      ]
    },
    {
      "id": "4e3b3a12-3b18-4bd2-ac24-25e39e1c171b",
      "name": "Parse Callback Response",
      "type": "n8n-nodes-base.code",
      "position": [
        480,
        360
      ]
    },
    {
      "id": "775e82a0-083b-4d1d-b31c-ce6069572e36",
      "name": "Route Based on Callback Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        700,
        320
      ]
    },
    {
      "id": "45561880-459f-4b5b-97b4-0f0d8185be2d",
      "name": "Update Approval Status",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        940,
        220
      ]
    },
    {
      "id": "a5990c44-03a0-4fe5-b822-be593b352559",
      "name": "Get Approved Row",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1140,
        220
      ]
    },
    {
      "id": "ca1d1ff9-9d0c-44eb-8e64-4c2785692c35",
      "name": "Notify User of Approval Result",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1340,
        220
      ]
    },
    {
      "id": "e5142ba0-50d8-450a-bbd1-45488cf6c386",
      "name": "Get Row for Detail View",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        940,
        420
      ]
    },
    {
      "id": "fe629ffa-ded8-4e94-bda9-a4206a928e06",
      "name": "Format Expense Detail Message",
      "type": "n8n-nodes-base.code",
      "position": [
        1140,
        420
      ]
    },
    {
      "id": "fd3f93a9-6664-4821-9a37-8e63bcafdd8d",
      "name": "Send Expense Detail to Supervisor",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1340,
        420
      ]
    },
    {
      "id": "461f7a4e-035b-4ed9-baa1-cd79586d2e3e",
      "name": "Show Income Input Format",
      "type": "n8n-nodes-base.code",
      "position": [
        940,
        580
      ]
    },
    {
      "id": "afbeeb5b-21a3-4a89-b85d-cc85ff6fe19a",
      "name": "Show Expense Input Format",
      "type": "n8n-nodes-base.code",
      "position": [
        940,
        740
      ]
    },
    {
      "id": "a7efd0d0-363f-4d27-9744-81e3eb9587a5",
      "name": "Send Income Format Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1140,
        580
      ]
    },
    {
      "id": "710ecddd-d353-41e7-8749-9a11e5816607",
      "name": "Send Expense Format Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1140,
        740
      ]
    },
    {
      "id": "936e41c7-727c-47db-a093-c0ad14b86f0e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1460,
        -1000
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "aca473db-b4b3-4b48-8bb8-9f213af8fd0f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1700,
        100
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "8065e1bb-a036-43dd-8427-1e98d9335339",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1000,
        100
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "75124148-3558-4cba-84fd-eb2dafba86a6",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1460,
        840
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    }
  ],
  "connections": {
    "Get Approved Row": {
      "main": [
        [
          {
            "node": "Notify User of Approval Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Data Type": {
      "main": [
        [
          {
            "node": "Route Based on Data Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Income Data": {
      "main": [
        [
          {
            "node": "Save Income to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Expense Data": {
      "main": [
        [
          {
            "node": "Save Expense to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect Message Type": {
      "main": [
        [
          {
            "node": "Route by Input Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Input Type": {
      "main": [
        [
          {
            "node": "Handle /start or Message Input",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Parse Callback Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Income to Sheet": {
      "main": [
        [
          {
            "node": "Notify User Income Recorded",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Expense to Sheet": {
      "main": [
        [
          {
            "node": "Notify User Expense Pending",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Approval Request": {
      "main": [
        []
      ]
    },
    "Validate Input Format": {
      "main": [
        [
          {
            "node": "Extract Data Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Approval Status": {
      "main": [
        [
          {
            "node": "Get Approved Row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Row for Detail View": {
      "main": [
        [
          {
            "node": "Format Expense Detail Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Callback Response": {
      "main": [
        [
          {
            "node": "Route Based on Callback Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Based on Data Type": {
      "main": [
        [
          {
            "node": "Parse Income Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Parse Expense Data",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Show Income Input Format": {
      "main": [
        [
          {
            "node": "Send Income Format Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Show Expense Input Format": {
      "main": [
        [
          {
            "node": "Send Expense Format Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify User Expense Pending": {
      "main": [
        [
          {
            "node": "Send Approval Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram - Incoming Webhook": {
      "main": [
        [
          {
            "node": "Detect Message Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Based on Callback Type": {
      "main": [
        [
          {
            "node": "Update Approval Status",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update Approval Status",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Row for Detail View",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Show Income Input Format",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Show Expense Input Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Expense Detail Message": {
      "main": [
        [
          {
            "node": "Send Expense Detail to Supervisor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle /start or Message Input": {
      "main": [
        [
          {
            "node": "Show Income/Expense Options",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Validate Input Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}