{
  "name": "Expense Logger — Telegram to Google Sheets (automation4mi)",
  "nodes": [
    {
      "parameters": {
        "content": "## רישום הוצאות מטלגרם\n\"קפה ומאפה 38 שקל\" → שורה בגיליון Google Sheets, עם סכום, קטגוריה ותאריך.\n\n**לפני הפעלה:**\n1. **Settings** — מזהה הצ'אט שלך\n2. צור גיליון עם הכותרות: date, amount, currency, category, description\n3. **Add row** — בחר את הגיליון\n4. credentials: Telegram, Anthropic, Google Sheets",
        "height": 300,
        "width": 480,
        "color": 4
      },
      "id": "33e4d785-286e-5a44-903a-d2d3db5f41e7",
      "name": "README",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -60,
        -330
      ]
    },
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "id": "1f9c1d2a-bd26-5d51-8db3-e79d89e77d75",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        100
      ],
      "webhookId": "ad1f90bc-6d39-5b1c-a6f2-3606a20c8dc6"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "145f411a-3fed-5770-a05e-56f5522f62b8",
              "name": "allowed_chat_id",
              "value": "PUT_YOUR_TELEGRAM_CHAT_ID",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "5f1c2373-9866-5530-8606-70ac9fc72a0e",
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        100
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "6a9ae533-409f-5d8d-9638-9780dbbc606b",
              "leftValue": "={{ String($('Telegram Trigger').item.json.message.chat.id) }}",
              "rightValue": "={{ $('Settings').item.json.allowed_chat_id }}",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "e750c56c-400b-5490-af93-10d135e2cdbd",
      "name": "Only my chat?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        440,
        100
      ]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=חלץ הוצאה מההודעה. היום: {{ $now.setZone('Asia/Jerusalem').toFormat('yyyy-MM-dd') }}.\n- amount: מספר בלבד. אם לא צוין סכום — 0.\n- currency: ILS אלא אם צוין אחרת.\n- category: אחת מ: סופר, מסעדות, תחבורה, דלק, בית, בריאות, ילדים, בילוי, אחר.\n- date: yyyy-MM-dd. \"אתמול\" = יום לפני היום.\n\nההודעה: {{ $('Telegram Trigger').item.json.message.text }}",
        "hasOutputParser": true
      },
      "id": "d39c5cd3-53e4-55af-b0f2-4eef6fabcbbc",
      "name": "Extract the expense",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.9,
      "position": [
        660,
        100
      ]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-5",
          "cachedResultName": "Claude Sonnet 5"
        },
        "options": {}
      },
      "id": "4a851b94-cda5-5474-bc3b-ca506f9f4669",
      "name": "Claude",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "typeVersion": 1.6,
      "position": [
        600,
        320
      ]
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"amount\": 42.5,\n  \"currency\": \"ILS\",\n  \"category\": \"סופר\",\n  \"description\": \"קניות שבועיות\",\n  \"date\": \"2026-10-14\"\n}"
      },
      "id": "b2b5da0a-f83e-592d-a7e4-2040991e0c42",
      "name": "Expense shape",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        760,
        320
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "4ed8140d-85c8-56f4-b12e-1ce2ca0985fa",
              "leftValue": "={{ $json.output.amount }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "73308aec-ee3e-55a3-acd9-d1db657036c6",
      "name": "Has an amount?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        900,
        100
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Sheet1"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "date": "={{ $json.output.date }}",
            "amount": "={{ $json.output.amount }}",
            "currency": "={{ $json.output.currency }}",
            "category": "={{ $json.output.category }}",
            "description": "={{ $json.output.description }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "date",
              "displayName": "date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "amount",
              "displayName": "amount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "currency",
              "displayName": "currency",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "category",
              "displayName": "category",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "description",
              "displayName": "description",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {}
      },
      "id": "3d7fe8b5-15b1-5312-bcaa-290d2c14d027",
      "name": "Add row",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1120,
        80
      ]
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "=נרשם ✅ {{ $('Extract the expense').item.json.output.amount }} {{ $('Extract the expense').item.json.output.currency }} · {{ $('Extract the expense').item.json.output.category }} · {{ $('Extract the expense').item.json.output.date }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "30c9aa95-a39c-5cc3-acd9-e5c5d5cac957",
      "name": "Confirm",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1340,
        80
      ]
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "=לא מצאתי סכום בהודעה. נסה למשל: \"סופר 230 שקל\"",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "e3b4ca48-035d-536c-bec9-5df68d5abdec",
      "name": "Ask for the amount",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1120,
        280
      ]
    }
  ],
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Only my chat?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only my chat?": {
      "main": [
        [
          {
            "node": "Extract the expense",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract the expense": {
      "main": [
        [
          {
            "node": "Has an amount?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has an amount?": {
      "main": [
        [
          {
            "node": "Add row",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Ask for the amount",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add row": {
      "main": [
        [
          {
            "node": "Confirm",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude": {
      "ai_languageModel": [
        [
          {
            "node": "Extract the expense",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Expense shape": {
      "ai_outputParser": [
        [
          {
            "node": "Extract the expense",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false,
    "source": "https://automation4mi.com/n8n-workflows.html"
  },
  "tags": []
}
