Back to Templates
  • +11

WhatsApp Expense Tracker with PostgreSQL Database & AI-Powered Reports

Created by

Roshan Ramani

Last update

Last update 8 days ago

Categories
Share

Track & Analyze Personal Finances with WhatsApp and AI Assistant

Effortless Money Management

Overview

This workflow turns WhatsApp messages into structured financial entries and logs them into a PostgreSQL database (or Google Sheets). It generates on-demand/scheduled summaries and sends them via WhatsApp, eliminating dashboards/spreadsheets.


Key Features

  • Convert free-form text to JSON:
    • date | category | type | amount | person
  • Auto-log transactions to PostgreSQL/Google Sheets
  • Instant WhatsApp confirmations after logging
  • Generate:
    • Daily summaries
    • Custom date-range reports (e.g., "April vs May")

Prerequisites

  1. n8n Instance: Self-hosted or n8n.cloud
  2. WhatsApp Business Cloud API:
    • App Token
    • Phone Number ID (replace +1234567890 with your number)
  3. PostgreSQL 12+:
    • Database: n8n_finances
    • Table: financial_transactions (schema below)
  4. (Optional) Google Sheets: OAuth credentials

PostgreSQL Table Schema

Column Type Description
date DATE Transaction date (YYYY-MM-DD)
category TEXT E.g., "Groceries"
type TEXT "Income", "Expense", or "Debt"
amount NUMERIC(12,2) Amount (e.g., 250.50)
person TEXT Optional (e.g., "Employer")

SQL Commands:

CREATE DATABASE n8n_finances;  
CREATE USER n8n_user WITH PASSWORD 'your_password';  
GRANT ALL PRIVILEGES ON DATABASE n8n_finances TO n8n_user;  

CREATE TABLE financial_transactions (  
  date DATE NOT NULL,  
  category TEXT NOT NULL,  
  type TEXT NOT NULL,  
  amount NUMERIC(12,2) NOT NULL,  
  person TEXT  
);  

Workflow Setup

Import Template

  1. Download the JSON file
  2. Upload to n8n Editor

Configure Credentials

  • WhatsApp Business Cloud:
    • App Token
    • Phone Number ID
  • PostgreSQL:
    • Host: localhost
    • Port: 5432
    • Database: n8n_finances
    • User: n8n_user
    • Password: your_password

Verify Table

Ensure financial_transactions table exists.


Usage Guide

1. Log Transactions

Send WhatsApp Message:

Spent 300 on Uber rides @ Uber

Workflow Output:

  • date = Today’s date
  • category = Uber rides
  • type = Expense
  • amount = 300
  • person = Uber

Confirmation:

✅ Logged: expense | Uber rides | ₹300.00 | Uber

2. Generate Reports

Daily Summary

  • Send: today's report
  • Response:
    • Income: ₹0.00
    • Expenses: ₹300.00
    • Savings: -₹300.00

Monthly Comparison

  • Send: March vs April report
  • Response:
    • Income: March ₹10,000 vs April ₹15,000 (+50%)
    • Expenses: March ₹8,000 vs April ₹6,000 (-25%)

Scheduled Report

  • Automatically sends at 8 AM daily:

Yesterday’s Total: Income ₹0 | Expenses ₹300 | Savings -₹300


Why It Matters

  • No spreadsheets: SQL handles calculations automatically.
  • Real-time tracking: Updates via WhatsApp in <5 seconds.
  • Natural language: Works with phrases like:

Paid 1500 for Netflix @ March billing


Unique Advantages

  • Zero apps: Entirely WhatsApp-based.
  • AI parsing: No rigid syntax required.
  • 1-click reports: No SQL knowledge needed.

Get Started

  1. Install Template: Import JSON into n8n.
  2. Configure Credentials: WhatsApp + PostgreSQL.
  3. Start Chatting:
    • Log expenses: Spent 500 on dinner @ Restaurant
    • Log income: Received 20000 salary @ Company
    • Get reports: today's report or Q1 vs Q2 report