{
  "name": "Expense Logger",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.3,
      "position": [
        0,
        0
      ],
      "id": "40a4a543-0457-43fc-9da2-51127412ebb5",
      "name": "Telegram Trigger",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4o-mini"
        },
        "responses": {
          "values": [
            {
              "content": "=Extract the expense amount and what the money was spent on from the user's message.\n\nUser message: {{ $json.message.text }}\n\nCategorize \"spent_on\" into one of:\nFood\nTransport\nShopping\nBills\nEntertainment\nHealth\nEducation\nOther\n\nAlong with category name, also write the thing that person bought/spent rupees on. For example, Shopping (Trekking Shows/Tshirt/Jacket, etc.), Food (Pizza/Drink/Gujarati Thali, etc.), Ticket Book (Railway/Flight/Bus, etc.) and so on. So, user get to know which thing they spent on. (Mention in brackets with category name)"
            }
          ]
        },
        "builtInTools": {},
        "options": {
          "textFormat": {
            "textOptions": {
              "type": "json_schema",
              "schema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"expense_value\": {\n      \"type\": \"number\"\n    },\n    \"spent_on\": {\n      \"type\": \"string\"\n    }\n  },\n  \"required\": [\"expense_value\", \"spent_on\"],\n  \"additionalProperties\": false\n}"
            }
          }
        }
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.3,
      "position": [
        208,
        0
      ],
      "id": "03b8053f-5bfc-484a-83d9-4b3748766330",
      "name": "Message a model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_GOOGLE_SHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Sheet1",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Expense Value": "=\u20b9{{ $json.output[0].content[0].text.expense_value }}",
            "Spent On": "={{ $json.output[0].content[0].text.spent_on }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Expense Value",
              "displayName": "Expense Value",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Spent On",
              "displayName": "Spent On",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        560,
        0
      ],
      "id": "8c69fe23-8ce1-48f4-b56f-45390320fbd0",
      "name": "Append row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "tg expense logger bot code: \n\nYOUR_TELEGRAM_BOT_TOKEN\n\nchatid: YOUR_TELEGRAM_CHAT_ID",
        "height": 176,
        "width": 256
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        -16
      ],
      "typeVersion": 1,
      "id": "bb834bcf-a0fa-4533-94ef-77e62530a5d9",
      "name": "Sticky Note"
    }
  ],
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "staticData": null,
  "triggerCount": 0,
  "meta": {
    "templateCredsSetupCompleted": true
  }
}