feature image

Building an AI-Powered Expense Tracker with n8n

🧠 Project Overview

This project is an agentic financial tracking system that uses Natural Language Processing (NLP) to simplify how users record and analyze their expenses. Instead of manually filling forms, users can just send a message (like “lunch 120”), and the system intelligently processes, categorizes, and stores the data.

At its core, the system combines Telegram, n8n workflows, MongoDB, and LLMs to create a seamless personal finance assistant.


⚙️ How the System Works

The workflow is designed as a pipeline that transforms raw user input into structured financial insights.

1. Input Layer (Telegram Trigger)

The process begins when a user sends a message via Telegram. This acts as the primary interface for interacting with the system.


2. Smart Classification

The system first determines what kind of message it is:

  • Daily expense
  • Online order
  • Income / money received
  • Question or conversation

This ensures the workflow takes the correct path.


3. Data Extraction (NLP Layer)

Using AI-powered extractors, the system pulls key information:

  • Item name
  • Amount
  • Category
  • Payment method
  • Notes / platform / status

This replaces manual data entry entirely.


4. Category Normalization

Instead of messy or inconsistent categories, the system:

  • Checks existing categories from the database
  • Matches similar ones (e.g., “coffee” → “Coffee / Tea / Drinks”)
  • Creates new ones only when needed

This keeps the data clean and scalable.


5. Database Storage

All structured data is stored in MongoDB with fields like:

  • USER_ID
  • ITEM
  • CATEGORY
  • AMOUNT
  • DATE
  • PAYMENT

This becomes the foundation for analytics and reporting.


6. File & Media Handling

If users upload images (like receipts), the system:

  • Downloads the file from Telegram
  • Stores it in Google Drive
  • Organizes it by date automatically

7. Weekly Automation & Insights

A scheduled workflow runs every week to:

  • Aggregate total spending
  • Identify highest expense
  • Break down spending by category

Then it sends a clean summary back to the user.

As defined in your workflow logic , the system:

  • Calculates total spend and transaction count
  • Finds the top expense
  • Groups data into categories
  • Aggregates similar items intelligently

📊 Example Output

The user receives a simple, readable report like:

 
📊 Weekly Spend Report
Total: ₹2,000 (25 transactions)

🏆 Highest Expense:
Headphones (₹1,200) – 12 Mar

📂 Category Breakdown:
• Food: ₹500
– Lunch: ₹300
– Snacks: ₹200
 

💡 Key Features

🔹 Natural Language Input

No forms. No friction. Just text.

🔹 AI-Based Categorization

Smart classification and normalization of expenses.

🔹 Automated Reports

Daily logs → Weekly insights without user effort.

🔹 Multi-Mode Tracking

Handles:

  • Offline spending
  • Online purchases
  • Income tracking

🔹 Scalable Architecture

Built using modular n8n workflows, making it easy to expand.


🧩 Tech Stack

  • n8n – Workflow automation engine
  • Telegram API – User interaction layer
  • MongoDB – Data storage
  • LLMs (DeepSeek) – NLP & reasoning
  • Google Drive – File storage

🧱 Challenges Faced

  • Handling inconsistent user inputs
  • Normalizing categories without duplication
  • Preventing LLM hallucinations in structured output
  • Maintaining speed while using multiple AI nodes

📚 What We Learned

  • How to design agentic workflows instead of simple automations
  • Importance of data normalization in long-term systems
  • Using LLMs as structured processors, not just chatbots
  • Building real-world automation pipelines with n8n

🔮 Future Improvements

  • Dashboard with charts & insights
  • Budget tracking and alerts
  • AI-based financial advice
  • Multi-user authentication system
  • Voice input support

🏁 Conclusion

This project shows how powerful automation becomes when combined with AI. What used to take manual effort is now reduced to a simple message. The system doesn’t just track expenses—it understands them, organizes them, and gives meaningful insights.

Leave a Reply

Your email address will not be published. Required fields are marked *