{
  "id": "F7mViwFsbCj9e7Xe",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Finance Management(copy)",
  "tags": [],
  "nodes": [
    {
      "id": "29348b2b-7acf-423c-86ae-c74030c6bd07",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -832,
        -352
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "9f3409c6-3b81-4f2c-a9ac-6043962dd8c4",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -624,
        -192
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "a75b2920-738f-4490-98a0-7e6041b66c33",
      "name": "Budget information extractor",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -16,
        -608
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "batching": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "25975fb8-0637-4c22-a82e-8d275b83c1a8",
      "name": "Google Gemini Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -16,
        -432
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2551dff4-7fc0-4850-a64f-8bde1842a705",
      "name": "Expense information extractor",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -16,
        -112
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "batching": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "69a34641-5579-4e16-b804-3e676c5dae36",
      "name": "Google Gemini Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -16,
        48
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1690b5c3-1281-4298-962e-047c8573f986",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        128,
        96
      ],
      "parameters": {
        "jsonSchemaExample": "\n{\n  \"type\": \"expense\",\n  \"Timestamp\": \"ISO datetime\",\n  \"Date\": \"DD/MM/YYYY\",\n  \"Account\": \"string\",\n  \"From\": \"string\",\n  \"To\": \"string\",\n  \"Type\": \"Debit or Credit\",\n  \"Category\": \"string\",\n  \"Description\": \"string\",\n  \"Amount\": \"number\",\n  \"Currency\": \"INR\",\n  \"Source\": \"Telegram\",\n  \"MessageId\": \"string\",\n  \"Status\": \"Posted\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "02ae4279-d0d0-4d4b-8026-6641368e9be3",
      "name": "Structured Output Parser1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        128,
        -400
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"type\": \"budget\",\n  \"Month\": \"MM-YYYY\",\n  \"Category\": \"string\",\n  \"Budget Amount\": \"number\",\n  \"Notes\": \"string\",\n  \"UpdatedAt\": \"ISO datetime\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "6160ac29-5fb2-45cc-957d-74d44eed0d47",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -832,
        720
      ],
      "parameters": {
        "filters": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyHour"
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "b2dc1c36-a6c4-4be7-a5a6-e697fb128a3f",
      "name": "Google Gemini Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -368,
        896
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "cffa1c59-7dba-49fa-8a72-576d389ed472",
      "name": "Google Gemini Chat Model4",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -32,
        896
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1d4b1582-8db3-4238-9a80-d6573e78e651",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1776,
        -752
      ],
      "parameters": {
        "color": 4,
        "width": 752,
        "height": 2272,
        "content": "## Smart Expense Tracker with Gmail + n8n + Google Sheets\n\n### \ud83d\udccc Summary\n\nThis workflow automates expense tracking by parsing bank transaction emails (HDFC, Indian Bank, IOB, UPI apps, etc.) and logging them directly into Google Sheets. It intelligently classifies, organizes, and updates budgets, providing monthly and yearly insights with zero manual effort.\n\n---\n\n### \ud83c\udfaf Who Is It For?\n\n* Individuals who want **personal finance automation**.\n* Families or groups needing **shared expense tracking**.\n* Professionals managing **multi-account (bank + UPI) transactions**.\n* Anyone tired of manual expense entry and reconciliation.\n\n---\n\n### \u2699\ufe0f Features\n\n* **Automated Gmail Parsing**: Reads bank/UPI alerts and extracts structured transaction details.\n* **Classification by Account**: Distinguishes between HDFC, Indian Bank, IOB, and UPI apps.\n* **Smart Filtering**: Ignores irrelevant or non-financial emails.\n* **Google Sheets Integration**:\n\n  * Logs transactions into the **Expenses** sheet.\n  * Maintains monthly budgets in the **Budgets** sheet.\n  * Tracks total spend, variance vs. budget, and generates alerts.\n* **Yearly Roll-Up**: At each month\u2019s end, logs total monthly expense into the **Yearly Summary** sheet.\n* **Alerts**: Notifies when expenses exceed the allocated budget.\n\n---\n\n### \ud83d\ude80 How To Use\n\n1. **Copy the Google Sheet template** with tabs: `Expenses`, `Budgets`, `Yearly Summary`.\n2. **Import the n8n workflow** provided.\n3. **Connect Gmail & Sheets** credentials inside n8n.\n4. **Customize Budget Categories** in the `Budgets` tab (e.g., Food, Rent, Travel).\n5. **Run Workflow** manually or set it on a schedule (e.g., every 5 minutes).\n\n---\n\n### \ud83d\udd27 Configuration Steps\n\n1. **Gmail Setup**\n\n   * Configure Gmail Trigger node with filters:\n\n     ```\n     from:(alerts@hdfcbank.net OR ealerts@iobnet.co.in OR alerts@indianbank.in)\n     ```\n   * Add UPI alert senders as needed.\n\n2. **LLM Parsing**\n\n   * LLM extracts JSON in schema:\n\n     ```json\n     {\n       \"date\": \"DD/MM/YYYY\",\n       \"account\": \"Bank/UPI name\",\n       \"from\": \"Sender email\",\n       \"to\": \"Recipient email\",\n       \"type\": \"Credit/Debit\",\n       \"category\": \"Expense Category\",\n       \"description\": \"Details\",\n       \"amount\": \"Number\",\n       \"currency\": \"INR\",\n       \"source\": \"Gmail\",\n       \"messageId\": \"Unique ID\",\n       \"status\": \"Posted/Pending\"\n     }\n     ```\n\n3. **Google Sheets**\n\n   * Map schema fields directly into `Expenses` sheet columns.\n   * Budget tab pre-filled with categories & monthly allocations.\n   * Yearly sheet auto-calculates monthly totals.\n\n4. **Alerts**\n\n   * Telegram node (optional) can notify when spending exceeds budget.\n\n---\n\n### \u2705 Benefits\n\n* No manual logging needed.\n* Real-time visibility into expenses.\n* Budget control with automatic alerts.\n* Scales from personal to family/shared use.\n* Works with any Gmail-supported bank or UPI provider.\n\n---\n\n\u26a1 With this setup, you can focus on spending wisely while your system takes care of the tracking.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "1b130cdf-9f6d-44ac-97ac-ade6da4aa2bc",
      "name": "Information extraction from telegram input",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -624,
        -352
      ],
      "parameters": {
        "text": "={{ $json.message.text }}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "=You are a strict financial data parser.  Given a text input from a human about budgets or expenses, detect the type and return ONLY a valid JSON object in the correct schema.  Classification rules: - If the message contains \"set budget\", \"budget for\", \"allocate\" \u2192 type = \"budget\" - If the message describes a transaction like \"paid\", \"give\", \"buy\", \"transfer\" \u2192 type = \"expense\"  SCHEMA:  For Budgets: {   \"type\": \"budget\",   \"Month\": \"{{ $today.month }}\"-\"{{ $today.year }}\",   \"Category\": \"string\",   \"Budget Amount\": number,   \"Notes\": \"string\",   \"UpdatedAt\": \"{{$now}}\" }  For Expenses: {   \"type\": \"expense\",   \"Timestamp\": \"{{$now}}\",   \"Date\": \"DD/MM/YYYY\",   \"Account\": \"string\",   \"From\": \"string\",   \"To\": \"string\",   \"Type\": \"Debit or Credit\",   \"Category\": \"string\",   \"Description\": \"string\",   \"Amount\": number,   \"Currency\": \"INR\",   \"Source\": \"Telegram\",   \"MessageId\": \"{{$json[\"message\"][\"message_id\"]}}\",   \"Status\": \"Posted\" }  RULES: - Always output exactly one JSON object. - Do not include any text outside the JSON object. - If any field is missing from the user message, use a reasonable default or leave it blank if truly unknown."
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "3b88a35a-b9b3-40ec-aa93-57dd1000070c",
      "name": "Raw check if the transaction is 'Budget' or 'Expense'",
      "type": "n8n-nodes-base.if",
      "position": [
        -272,
        -352
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "fc41ad95-ebe6-45a4-b6d0-5446d862c662",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ JSON.parse($json.text.replace(/```json\\n?|```/g, '').trim()).type }}",
              "rightValue": "budget"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "7f10537f-0feb-4783-b4ff-ea89f6b4cf9f",
      "name": "Check if the transaction is 'Budget' or 'Expense'",
      "type": "n8n-nodes-base.if",
      "position": [
        384,
        -352
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "342b8a96-903d-4e39-a54c-4404f1e22f6a",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.output.type }}",
              "rightValue": "budget"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "eabb8a18-e5d7-416c-9ab1-c6165350737e",
      "name": "Append transaction data to budget sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        704,
        -464
      ],
      "parameters": {
        "columns": {
          "value": {
            "Month": "={{ $json.output.Month }}",
            "Notes": "={{ $json.output.Notes }}",
            "Category": "={{ $json.output.Category }}",
            "Updated At": "={{ $json.output.UpdatedAt }}",
            "Budget Amount": "={{ $json.output['Budget Amount'] }}"
          },
          "schema": [
            {
              "id": "Month",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Month",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Category",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Category",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Budget Amount",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Budget Amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Notes",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Notes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Updated At",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Updated At",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1801603029,
          "cachedResultUrl": "https://docs.google.YOUR_AWS_SECRET_KEY_HERE_9t4B3SSZPIv62-AchIUF14/edit#gid=1801603029",
          "cachedResultName": "Budgets"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fDiKZVLB07hqjNh4Zr6d_9t4B3SSZPIv62-AchIUF14",
          "cachedResultUrl": "https://docs.google.YOUR_AWS_SECRET_KEY_HERE_9t4B3SSZPIv62-AchIUF14/edit?usp=drivesdk",
          "cachedResultName": "Finances"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "769f49cc-badb-4770-97c4-351a08e80f1c",
      "name": "Append transaction data to expense sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        704,
        -256
      ],
      "parameters": {
        "columns": {
          "value": {
            "To": "={{ $json.output.To }}",
            "Date": "={{ $json.output.Date }}",
            "From": "={{ $json.output.From }}",
            "Type": "={{ $json.output.Type }}",
            "Amount": "={{ $json.output.Amount }}",
            "Source": "={{ $json.output.Source }}",
            "Status": "={{ $json.output.Status }}",
            "Account": "={{ $json.output.Account }}",
            "Category": "={{ $json.output.Category }}",
            "Currency": "={{ $json.output.Currency }}",
            "MessageId": "={{ $json.output.MessageId }}",
            "Timestamp": "={{ $json.output.Timestamp }}",
            "Description": "={{ $json.output.Description }}"
          },
          "schema": [
            {
              "id": "Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Account",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Account",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "From",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "From",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "To",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "To",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Type",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Category",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Category",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Amount",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Currency",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Currency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Source",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Source",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "MessageId",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "MessageId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1752386962,
          "cachedResultUrl": "https://docs.google.YOUR_AWS_SECRET_KEY_HERE_9t4B3SSZPIv62-AchIUF14/edit#gid=1752386962",
          "cachedResultName": "Expenses"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fDiKZVLB07hqjNh4Zr6d_9t4B3SSZPIv62-AchIUF14",
          "cachedResultUrl": "https://docs.google.YOUR_AWS_SECRET_KEY_HERE_9t4B3SSZPIv62-AchIUF14/edit?usp=drivesdk",
          "cachedResultName": "Finances"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "55fbe444-feb4-400b-a0e3-d95d8fc900e2",
      "name": "Send a confirmation reply to the user",
      "type": "n8n-nodes-base.telegram",
      "position": [
        976,
        -384
      ],
      "parameters": {
        "text": "=Sure, the entry has been added to the finance sheet. You can check the finance sheet by clicking the below link \ud83d\udc47\n\nhttps://docs.google.com/spreadsheets/d/1fDiKZVLB07hqjNh4Zr6d_9t4B3SSZPIv62-AchIUF14/edit?usp=sharing\n\nThank you \ud83d\ude0a",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "93278ce8-0c1e-4893-8e5f-a4a00190cce0",
      "name": "Extract the email only from specified bank/UPI apps or the transactions made from them",
      "type": "n8n-nodes-base.code",
      "position": [
        -608,
        720
      ],
      "parameters": {
        "jsCode": "const emailBody = $input.first().json.snippet || \"\";\nconst senderEmail = $input.first().json.From || \"\";\n\n// Account detection\nlet account = \"\";\nif (/alerts@hdfcbank\\.net/i.test(senderEmail)) account = \"HDFC Bank\";\nelse if (/ealerts@iobnet\\.co\\.in/i.test(senderEmail)) account = \"Indian Overseas Bank\";\nelse if (/alerts@indianbank\\.in/i.test(senderEmail)) account = \"Indian Bank\";\nelse if (/@upi|@okhdfcbank|@okaxis|@okicici/i.test(emailBody)) {\n    if (/gpay|google pay/i.test(emailBody)) account = \"Google Pay\";\n    else if (/phonepe/i.test(emailBody)) account = \"PhonePe\";\n    else if (/paytm/i.test(emailBody)) account = \"Paytm\";\n    else account = \"UPI\";\n} else {\n    account = \"Other\";\n}\n\n// If account is \"Other\", skip output\nif (account === \"Other\") {\n    return [];\n}\n\n// Output\nreturn [{\n    account,\n    from: senderEmail, // exact Gmail \"From\" metadata\n    snippet: emailBody,\n    messageId: $input.first().json.id || \"\"\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "7799b2b4-ce6a-461b-b7b0-2af4e7ce3808",
      "name": "Generate the structured data from the raw emails",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -368,
        720
      ],
      "parameters": {
        "text": "={{ $json.snippet }}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "=You are a financial transaction parser for HDFC Bank, Indian Overseas Bank, and Indian Bank credit/debit alert emails.  \nYou only respond with a JSON object in this exact format and nothing else:\n\ninput: {{ $json.snippet }}\n{\n  \"date\": \"YYYY-MM-DD or ''\",\n  \"account\": \"{{ $json.account }}\",\n  \"from\": \"{{ $json.from }}\",\n  \"to\": \"Receiver or merchant or ''\",\n  \"type\": \"Credit or Debit\",\n  \"category\": \"Category based on merchant or purpose\",\n  \"description\": \"Full transaction description from email\",\n  \"amount\": \"Numeric value without currency symbol or commas\",\n  \"currency\": \"INR\",\n  \"source\": \"Gmail\",\n  \"messageId\": \"{{ $json.messageId }}\",\n  \"status\": \"Posted\"\n}\n\nRules:\n1. Process only credit/debit alerts. Ignore promotional, loan, OTP, or info emails.\n2. `account` and `from` are already provided \u2014 never change them.\n3. `to` = merchant/payee for debit, your account for credit.\n4. Extract `amount` as a plain number (no commas or currency symbol).\n5. Guess `category` from merchant/purpose. Leave \"\" if unsure.\n6. `date` in YYYY-MM-DD. If missing, use today\u2019s date.\n7. Return only the JSON object. No explanations.\n"
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "d6cb28d2-b720-4709-a56d-623cdb7ef7f7",
      "name": "Extract the information and parse it",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        -32,
        720
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {},
        "schemaType": "fromJson",
        "jsonSchemaExample": "{\n  \"date\": \"string (format: DD/MM/YYYY)\",\n  \"account\": \"string\",\n  \"from\": \"string (name or email)\",\n  \"to\": \"string (name or email)\",\n  \"type\": \"string (Credit/Debit)\",\n  \"category\": \"string\",\n  \"description\": \"string\",\n  \"amount\": \"number\",\n  \"currency\": \"string (ISO code e.g. INR)\",\n  \"source\": \"string (e.g. Gmail, Telegram)\",\n  \"messageId\": \"string\",\n  \"status\": \"string (e.g. Posted, Pending)\"\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "ee90ad8e-4479-4388-b72a-12c9803f0edf",
      "name": "Check if the transaction is 'Credit' or 'Debit'",
      "type": "n8n-nodes-base.if",
      "position": [
        304,
        720
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c7ff91d0-830f-4b19-a407-e17f79b2e263",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.output.type }}",
              "rightValue": "Credit"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "23324adf-301d-4712-b27a-1a3447fee5c8",
      "name": "Append transaction data to expense sheet1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        560,
        544
      ],
      "parameters": {
        "columns": {
          "value": {
            "To": "={{ $json.output.to }}",
            "Date": "={{ $json.output.date }}",
            "From": "={{ $json.output.from }}",
            "Type": "={{ $json.output.type }}",
            "Amount": "={{ $json.output.amount }}",
            "Source": "={{ $json.output.source }}",
            "Status": "={{ $json.output.status }}",
            "Account": "={{ $json.output.account }}",
            "Category": "={{ $json.output.category }}",
            "Currency": "={{ $json.output.currency }}",
            "MessageId": "={{ $json.output.messageId }}",
            "Timestamp": "=",
            "Description": "={{ $json.output.description }}"
          },
          "schema": [
            {
              "id": "Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Account",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Account",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "From",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "From",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "To",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "To",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Type",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Category",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Category",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Amount",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Currency",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Currency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Source",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Source",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "MessageId",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "MessageId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1752386962,
          "cachedResultUrl": "https://docs.google.YOUR_AWS_SECRET_KEY_HERE_9t4B3SSZPIv62-AchIUF14/edit#gid=1752386962",
          "cachedResultName": "Expenses"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fDiKZVLB07hqjNh4Zr6d_9t4B3SSZPIv62-AchIUF14",
          "cachedResultUrl": "https://docs.google.YOUR_AWS_SECRET_KEY_HERE_9t4B3SSZPIv62-AchIUF14/edit?usp=drivesdk",
          "cachedResultName": "Finances"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "15b46ac4-e38e-4b83-bde8-de754b230350",
      "name": "Append transaction data to expense sheet2",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        544,
        912
      ],
      "parameters": {
        "columns": {
          "value": {
            "To": "={{ $json.output.to }}",
            "Date": "={{ $json.output.date }}",
            "From": "={{ $json.output.from }}",
            "Type": "={{ $json.output.type }}",
            "Amount": "={{ $json.output.amount }}",
            "Source": "={{ $json.output.source }}",
            "Status": "={{ $json.output.status }}",
            "Account": "={{ $json.output.account }}",
            "Category": "={{ $json.output.category }}",
            "Currency": "={{ $json.output.currency }}",
            "MessageId": "={{ $json.output.messageId }}",
            "Timestamp": "=",
            "Description": "={{ $json.output.description }}"
          },
          "schema": [
            {
              "id": "Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Account",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Account",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "From",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "From",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "To",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "To",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Type",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Category",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Category",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Amount",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Currency",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Currency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Source",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Source",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "MessageId",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "MessageId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1752386962,
          "cachedResultUrl": "https://docs.google.YOUR_AWS_SECRET_KEY_HERE_9t4B3SSZPIv62-AchIUF14/edit#gid=1752386962",
          "cachedResultName": "Expenses"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fDiKZVLB07hqjNh4Zr6d_9t4B3SSZPIv62-AchIUF14",
          "cachedResultUrl": "https://docs.google.YOUR_AWS_SECRET_KEY_HERE_9t4B3SSZPIv62-AchIUF14/edit?usp=drivesdk",
          "cachedResultName": "Finances"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "f94f965a-ac92-4759-a269-2c41c303c5fd",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -864,
        -656
      ],
      "parameters": {
        "width": 2080,
        "height": 912,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "a65121d0-719b-48ae-80b2-1ba699aa5358",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        -656
      ],
      "parameters": {
        "width": 800,
        "height": 224,
        "content": "Takes input from a telegram bot which is connected to the n8n workflow telegram trigger.\n\nGemini AI Parser extracts structured details (date, amount, category, etc.).\n\nThen it checks, whether the manually specified details is \u2018budget\u2019 or \u2018expense\u2019, then splits the data -> parse the data -> then again check whether it is \u2018Budget\u2019 or \u2018Expense\u2019 then appends the structured data to the respective google sheet.\n\nMonthly summary auto-calculates the expense and updates the expense for every month and budgets(sum all budgets if there are more than 1 budgets)."
      },
      "typeVersion": 1
    },
    {
      "id": "c42b224d-83c9-49ba-84a0-598dddad5586",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        496
      ],
      "parameters": {
        "color": 3,
        "width": 1680,
        "height": 736,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "2b21cea9-9e6a-40f4-9961-e0d6b2fa00c9",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        816,
        512
      ],
      "parameters": {
        "color": 3,
        "width": 832,
        "height": 288,
        "content": "Gmail Trigger captures new bank/UPI emails.\n\nGemini AI Parser extracts structured details (date, amount, category, etc.).\n\nFilter Node ensures only valid financial transactions are logged.\n\nInformation extractor will extract the information like Date, account, transaction type(Credit/Debit), description, currency, status, messageId, from email, to email, category -> checks if the transaction is \u2018Credit\u2019 or \u2018Debit\u2019 then appends the details to the respective google sheet\n\nBudget Validator checks against monthly allocations.\n\nIf the expense is above the budget is raises an alert and will send a email to the connected account."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "48585f82-44de-4fa7-bc8c-a25001de6e5b",
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Extract the email only from specified bank/UPI apps or the transactions made from them",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Information extraction from telegram input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Information extraction from telegram input",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Expense information extractor",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Budget information extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Expense information extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Generate the structured data from the raw emails",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model4": {
      "ai_languageModel": [
        [
          {
            "node": "Extract the information and parse it",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "Budget information extractor",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Budget information extractor": {
      "main": [
        [
          {
            "node": "Check if the transaction is 'Budget' or 'Expense'",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Expense information extractor": {
      "main": [
        [
          {
            "node": "Check if the transaction is 'Budget' or 'Expense'",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract the information and parse it": {
      "main": [
        [
          {
            "node": "Check if the transaction is 'Credit' or 'Debit'",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append transaction data to budget sheet": {
      "main": [
        [
          {
            "node": "Send a confirmation reply to the user",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append transaction data to expense sheet": {
      "main": [
        [
          {
            "node": "Send a confirmation reply to the user",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Information extraction from telegram input": {
      "main": [
        [
          {
            "node": "Raw check if the transaction is 'Budget' or 'Expense'",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if the transaction is 'Credit' or 'Debit'": {
      "main": [
        [
          {
            "node": "Append transaction data to expense sheet1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Append transaction data to expense sheet2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate the structured data from the raw emails": {
      "main": [
        [
          {
            "node": "Extract the information and parse it",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if the transaction is 'Budget' or 'Expense'": {
      "main": [
        [
          {
            "node": "Append transaction data to budget sheet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Append transaction data to expense sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Raw check if the transaction is 'Budget' or 'Expense'": {
      "main": [
        [
          {
            "node": "Budget information extractor",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Expense information extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract the email only from specified bank/UPI apps or the transactions made from them": {
      "main": [
        [
          {
            "node": "Generate the structured data from the raw emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}