{
  "id": "IvyhZDPvldIGYyRO",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Smart Financial Health Tracker with AI Insights",
  "tags": [],
  "nodes": [
    {
      "id": "9b1769a5-53fa-434f-99a0-1da66b5f2a03",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -912,
        -256
      ],
      "parameters": {
        "width": 384,
        "height": 1104,
        "content": "# Smart Financial Health Tracker with AI Insights\n\n# How it works:\nThis workflow collects user financial data through a form and validates it to ensure accuracy. It then calculates saving, investment, expense, and overall financial health scores. Based on the results, the system determines the user's financial status. An AI node generates personalized financial advice. It also monitors high expenses and triggers alerts if needed. Finally, all data is stored in Google Sheets and shared on Slack for real-time updates.\n# Setup Steps:\n## Financial data collection\nCreate a form with fields for income, savings investments, and expenses. check for data validation and compute the financial score.\n\n## Function node\nUse function node for  financial score computation.\n\n## Add AI credentials for advice\nConnect the AI node it gives the recommendation\n\n## Add function node and wait after AI node\nIt gives the expense alert and wait used for execution delay\n\n## Add google sheet\nIt is the financial data storage sheet.\n\n\n## Edit field and slack \nThis field format the output and send message to the slack channel.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "31a82f6f-8f24-4753-8f41-5d9dbcb2267d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -512,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 720,
        "height": 432,
        "content": "## Financial Data Collection and Computation\n\nCollect user financial details such as income, savings, investments, and expenses. Organize this data for processing. then check the data is valid or not. Compute saving, investment, and expense scores, calculate the final financial health score, and generate insights for personalized recommendations and expense alerts."
      },
      "typeVersion": 1
    },
    {
      "id": "89292193-cf18-4e9e-bcf4-9ab20449bc0f",
      "name": "Groq Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "position": [
        320,
        448
      ],
      "parameters": {
        "model": "openai/gpt-oss-20b",
        "options": {}
      },
      "credentials": {
        "groqApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1c1312e2-5e8c-4a10-af08-ecd9ee1201f7",
      "name": "Financial input",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -480,
        240
      ],
      "parameters": {
        "options": {},
        "formTitle": "Financial Habit Score Tracker",
        "formFields": {
          "values": [
            {
              "fieldName": "Monthly Income",
              "fieldType": "number",
              "fieldLabel": "Monthly Income",
              "requiredField": true
            },
            {
              "fieldName": "Amount Saved",
              "fieldType": "number",
              "fieldLabel": "Amount Saved"
            },
            {
              "fieldName": "Amount Invested",
              "fieldLabel": "Amount Invested"
            },
            {
              "fieldName": "Expenses",
              "fieldLabel": "Expenses"
            }
          ]
        },
        "formDescription": "Track your weekly saving and investment habits to evaluate your financial health. Fill in your income, savings, and investment details to receive a personalized financial health score and insights."
      },
      "typeVersion": 2.4
    },
    {
      "id": "6fcab8e4-f9fc-490f-9b24-3111bb77cec7",
      "name": "Financial Data Preparation",
      "type": "n8n-nodes-base.set",
      "position": [
        -320,
        240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f030093c-0fab-4b7e-bd84-74c8c0f69c0e",
              "name": "=income",
              "type": "number",
              "value": "={{$json[\"Monthly Income\"]}}"
            },
            {
              "id": "9d9dd5a8-0deb-4f2c-b8d3-e77e45c2386c",
              "name": "saved",
              "type": "number",
              "value": "={{$json[\"Amount Saved\"]}}"
            },
            {
              "id": "c0741cc3-e371-425c-a707-fde8eef7a07f",
              "name": "invested",
              "type": "number",
              "value": "={{$json[\"Amount Invested\"]}}"
            },
            {
              "id": "06339431-a29f-4e0d-91f8-6365e4c6803a",
              "name": "savingRatio",
              "type": "string",
              "value": "={{$json[\"Amount Saved\"] / $json[\"Monthly Income\"]}}"
            },
            {
              "id": "99f254bc-9fc5-48e0-8162-e8124a2b34d5",
              "name": "investmentRatio",
              "type": "string",
              "value": "={{$json[\"Amount Invested\"] / $json[\"Monthly Income\"]}}"
            },
            {
              "id": "dcfd7838-13fd-4032-90de-3f80fb00165a",
              "name": "expenses",
              "type": "string",
              "value": "={{$json[\"Expenses\"]}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "2832689c-0aaa-4e9e-81f6-4264c9e31378",
      "name": "Financial Score Computation",
      "type": "n8n-nodes-base.code",
      "position": [
        64,
        224
      ],
      "parameters": {
        "jsCode": "const income = Number($json.income);\nconst saved = Number($json.saved);\nconst invested = Number($json.invested);\nconst expenses = Number($json.expenses);\n\n// Handle zero income\nif (income === 0) {\n  return [{\n    json: {\n      income,\n      saved,\n      invested,\n      expenses,\n      savingScore: 0,\n      investmentScore: 0,\n      expenseScore: 0,\n      finalScore: 0,\n      status: \"Income cannot be zero\"\n    }\n  }];\n}\n\n// Ratios\nlet savingRatio = saved / income;\nlet investmentRatio = invested / income;\nlet expenseRatio = expenses / income;\n\n//  Saving Score (higher is better)\nlet savingScore = 0;\nif (savingRatio >= 0.3) savingScore = 100;\nelse if (savingRatio >= 0.2) savingScore = 70;\nelse if (savingRatio > 0) savingScore = 40;\nelse savingScore = 0;\n\n//  Investment Score (higher is better)\nlet investmentScore = 0;\nif (investmentRatio >= 0.2) investmentScore = 100;\nelse if (investmentRatio > 0) investmentScore = 60;\nelse investmentScore = 0;\n\n//  Expense Score (lower expense = better)\nlet expenseScore = 0;\nif (expenseRatio <= 0.5) expenseScore = 100;\nelse if (expenseRatio <= 0.7) expenseScore = 60;\nelse expenseScore = 30;\n\n//  Final Score (average of all 3)\nlet finalScore = (savingScore + investmentScore + expenseScore) / 3;\n\n//  Status\nlet status = \"\";\nif (finalScore >= 80) status = \"Excellent\";\nelse if (finalScore >= 50) status = \"Good\";\nelse status = \"Needs Improvement\";\n\n//  Return ALL fields (important for Google Sheets)\nreturn [{\n  json: {\n    income,\n    saved,\n    invested,\n    expenses,\n    savingScore,\n    investmentScore,\n    expenseScore,\n    finalScore: finalScore.toFixed(2),\n    status\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "d8d68645-dfde-4597-bd7d-84eece140c36",
      "name": "Personalized Financial Insights",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        336,
        224
      ],
      "parameters": {
        "text": "=Analyze this financial data:\n\nIncome: {{$json.income}}\nSavings: {{$json.saved}}\nInvestments: {{$json.invested}}\nExpenses: {{$json.expenses}}\nFinal Score: {{$json.finalScore}}\n\nGive a short personalized financial advice in 1-2 lines.",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "715fe228-3ea4-48b2-9b9d-e578e23843b0",
      "name": "Expense Monitoring & Alerts",
      "type": "n8n-nodes-base.code",
      "position": [
        656,
        224
      ],
      "parameters": {
        "jsCode": "const income = Number($json.income);\nconst expenses = Number($json.expenses);\n\nlet alert = \"\";\n\nif (expenses > income * 0.7) {\n    alert = \"Warning : Your expenses are very high!\";\n} else if (expenses > income * 0.5) {\n    alert = \"Caution: Keep an eye on your expenses.\";\n} else {\n    alert = \"Good! Expenses are under control.\";\n}\n\nreturn [{ json: { ...$json, expenseAlert: alert } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "c4353dcf-3b46-44db-b15d-f3b0570fd55f",
      "name": "Google Sheets Data Storage",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1184,
        224
      ],
      "parameters": {
        "columns": {
          "value": {
            "Date": "={{ $now.toFormat('yyyy-MM-dd') }}",
            "saved": "={{ $('Financial Score Computation').item.json.saved }}",
            "income": "={{ $('Financial Score Computation').item.json.income }}",
            "status": "={{ $('Financial Score Computation').item.json.status }}",
            "expenses": "={{ $('Financial Data Preparation').item.json.expenses }}",
            "invested": "={{ $('Financial Score Computation').item.json.invested }}",
            "finalScore": "={{ $('Financial Score Computation').item.json.finalScore }}",
            "savingScore": "={{ $('Financial Score Computation').item.json.savingScore }}",
            "investmentScore": "={{ $('Financial Score Computation').item.json.investmentScore }}"
          },
          "schema": [
            {
              "id": "income",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "income",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "saved",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "saved",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "invested",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "invested",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "expenses",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "expenses",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "savingScore",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "savingScore",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "investmentScore",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "investmentScore",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "finalScore",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "finalScore",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Top_Recommendation ",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Top_Recommendation ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ggWPTMYV22fUtHpLUtxJjJLl79UC3NWGyViV1elV9pk/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ggWPTMYV22fUtHpLUtxJjJLl79UC3NWGyViV1elV9pk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ggWPTMYV22fUtHpLUtxJjJLl79UC3NWGyViV1elV9pk/edit?usp=drivesdk",
          "cachedResultName": "financial sheet"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "0c2d6f7d-f97e-4746-ad37-79dfc4e6890b",
      "name": "Output Formatting",
      "type": "n8n-nodes-base.set",
      "position": [
        1408,
        224
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "827589c2-3264-4f9a-998b-f4d83a6cf050",
              "name": "message",
              "type": "string",
              "value": "=Your Financial Score is {{ $('Financial Score Computation').item.json.finalScore }}"
            },
            {
              "id": "f0b59abd-b79b-409c-a9d7-b9e613dd9381",
              "name": "summary",
              "type": "string",
              "value": "=Status: {{ $('Financial Score Computation').item.json.status }}"
            },
            {
              "id": "73a3f8dd-b5a4-4b7d-a0f7-931aefdef0b7",
              "name": "saving score",
              "type": "string",
              "value": "=Saving Score:  {{ $('Financial Score Computation').item.json.savingScore }} "
            },
            {
              "id": "8c338d13-140f-4bd8-969d-34ef3223691d",
              "name": "investment",
              "type": "string",
              "value": "=Investment Score: {{ $('Financial Score Computation').item.json.investmentScore }}"
            },
            {
              "id": "7faf6cd9-6913-45c4-bc0b-9d25f99ad3fa",
              "name": "expenses",
              "type": "string",
              "value": "=Expenses: {{ $('Financial Score Computation').item.json.expenses }}"
            },
            {
              "id": "2468b9bf-528d-4976-a140-45d29dce6fba",
              "name": "AI Advice",
              "type": "string",
              "value": "={{ $('Personalized Financial Insights').item.json.output }}"
            },
            {
              "id": "d2a3ddae-eb4f-4215-836e-85767e5c3d01",
              "name": "Expense Alert",
              "type": "string",
              "value": "={{ $('Expense Monitoring & Alerts').item.json.expenseAlert }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "74c13c6b-c490-40c1-9631-30ad641cbeee",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 768,
        "height": 576,
        "content": "## AI Advice, Expense Monitoring, and Processing Delay\n\nThe AI node provides short personalized financial advice based on user data. The Expense Monitoring node checks spending and generates alerts if needed. A Wait node adds a short delay to ensure smooth processing before storing and sending the final financial insights."
      },
      "typeVersion": 1
    },
    {
      "id": "d04aa134-a2d2-4601-9fd7-b17680f99a93",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1088,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 768,
        "height": 480,
        "content": "\n## Data Storage and Notification\n\nThe Google Sheets node stores all financial inputs, scores, and status for tracking. The Output Formatting node structures the results clearly with scores, AI advice, and alerts. Finally, the Slack node sends the formatted summary to a channel for real-time updates and quick insights.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "f5e45efe-15f1-4361-9cc7-88435c50ec4c",
      "name": "Processing Delay Before Data Storage",
      "type": "n8n-nodes-base.wait",
      "position": [
        864,
        224
      ],
      "parameters": {
        "amount": 2
      },
      "typeVersion": 1.1
    },
    {
      "id": "3efb1413-321c-4fe5-8011-fb28fad06739",
      "name": "Slack Alert",
      "type": "n8n-nodes-base.slack",
      "position": [
        1616,
        224
      ],
      "parameters": {
        "text": "=message: {{ $json.message }} \n  {{ $json.summary }}\n {{ $json['saving score'] }}\n {{ $json.investment }}\nExpenses: {{ $json.expenses }}\nAI Advice: {{ $json['AI Advice'] }}\nExpense Alert: {{ $json['Expense Alert'] }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C0AQ84RN6DV",
          "cachedResultName": "financial-score-check"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.4
    },
    {
      "id": "c99d92b6-10d1-49d6-a107-c4d8e765477f",
      "name": "Input Validation Check",
      "type": "n8n-nodes-base.if",
      "position": [
        -160,
        240
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "d8454af6-4b1b-4f24-b627-0e059e939c75",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.income  && $json.saved  && $json.invested  && $json.expenses  }}",
              "rightValue": 0
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    }
  ],
  "active": false,
  "settings": {
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "7fdce796-0843-417c-9779-fdc662a81355",
  "connections": {
    "Financial input": {
      "main": [
        [
          {
            "node": "Financial Data Preparation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Groq Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Personalized Financial Insights",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Output Formatting": {
      "main": [
        [
          {
            "node": "Slack Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Input Validation Check": {
      "main": [
        [
          {
            "node": "Financial Score Computation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Financial Data Preparation": {
      "main": [
        [
          {
            "node": "Input Validation Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets Data Storage": {
      "main": [
        [
          {
            "node": "Output Formatting",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Expense Monitoring & Alerts": {
      "main": [
        [
          {
            "node": "Processing Delay Before Data Storage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Financial Score Computation": {
      "main": [
        [
          {
            "node": "Personalized Financial Insights",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Personalized Financial Insights": {
      "main": [
        [
          {
            "node": "Expense Monitoring & Alerts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Processing Delay Before Data Storage": {
      "main": [
        [
          {
            "node": "Google Sheets Data Storage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}