Skip to main content

WhatsApp expense tracker with PostgreSQL database & AI-powered reports

Workflow preview

Workflow preview
100%
WhatsApp expense tracker with PostgreSQL database & AI-powered reports preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Track Personal Finances with WhatsApp and AI Assistant Transform your WhatsApp into a powerful personal finance command center. This AI powered workflow converts natural language messages into stru...

Best for

  • Personal Productivity automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.toolcode, @n8n/n8n-nodes-langchain.outputparserstructured, @n8n/n8n-nodes-langchain.lmchatopenrouter, @n8n/n8n-nodes-langchain.toolcalculator, n8n-nodes-base.postgrestool, n8n-nodes-base.converttofile, n8n-nodes-base.whatsapp, n8n-nodes-base.whatsapptrigger

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Roshan Ramani.

Original n8n.io source

1.1 Workflow description

Title
WhatsApp expense tracker with PostgreSQL database & AI-powered reports
Workflow name
WhatsApp expense tracker with PostgreSQL database & AI-powered reports

Track Personal Finances with WhatsApp and AI Assistant

Transform your WhatsApp into a powerful personal finance command center. This AI-powered workflow converts natural language messages into structured financial data, automates record-keeping, and delivers instant insights—all within your favorite messaging app.

Who is this for?

This template is perfect for:

  • Personal finance enthusiasts who want effortless expense tracking
  • Small business owners managing personal and business expenses
  • Freelancers tracking income and expenses across projects
  • Anyone who prefers messaging over complex finance apps
  • Users seeking privacy with self-hosted financial data

What problem is this workflow solving?

Traditional expense tracking requires switching between apps, manual data entry, and complex spreadsheets. Most people abandon these systems within weeks. This workflow solves the friction by:

  • Eliminating app-switching—everything happens in WhatsApp
  • Converting natural language to structured data automatically
  • Providing instant confirmations and reports
  • Requiring zero learning curve or behavior change

What this workflow does

Smart Transaction Processing

Send natural messages like Spent 300 on groceries at Walmart and the AI automatically extracts:

  • Date: Today's date (or specified date)
  • Category: Groceries
  • Type: Expense/Income/Debt
  • Amount: 300
  • Person/Company: Walmart

Intelligent Message Classification

The workflow automatically routes messages to three processing branches:

  • Branch 1: Reports and analytics (show March expenses)
  • Branch 2: Transaction logging (spent 50 on coffee)
  • Branch 3: General financial chat (how can I save money?)

Advanced Reporting

Generate instant reports by messaging:

  • today's report → Daily income/expense summary
  • March vs April report → Monthly comparisons with percentages
  • show groceries spending → Category-specific analysis
  • Automatic daily summaries at your preferred time

Database Integration

All transactions are stored in PostgreSQL with proper schema:

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

Setup

Prerequisites

  • n8n instance (self-hosted or n8n.cloud)
  • WhatsApp Business Cloud API credentials
  • PostgreSQL database (version 12+)
  • OpenRouter API key for AI processing

Quick Setup Steps

  1. Import the workflow template into your n8n instance
  2. Configure credentials:
  • WhatsApp Business Cloud API (App Token + Phone Number ID)
  • PostgreSQL connection details
  • OpenRouter API key for AI processing
  1. Create database table using the provided SQL schema
  2. Test the connection by sending a sample message
  3. Customize the scheduled report timing (default: 8 AM daily)

Verification Checklist

  • WhatsApp webhook receives messages
  • AI correctly parses transaction messages
  • Database insertions work properly
  • Confirmation messages are sent back
  • Reports generate with accurate data

How to customize this workflow to your needs

AI Model Configuration

  • Default: Uses OpenRouter with GPT-3.5-turbo for cost efficiency
  • Upgrade: Switch to GPT-4 or Claude for better accuracy
  • Local: Replace with self-hosted Ollama for complete privacy

Database Options

  • PostgreSQL: Recommended for production use
  • Google Sheets: Alternative for simpler setups (nodes included)
  • MySQL/SQLite: Easily adaptable with minor SQL modifications

Message Classification

Customize the classification system:

  • 0: Reports (modify SQL queries for different analytics)
  • 1: Transactions (adjust parsing rules for your language/currency)
  • 2: Chat (customize AI responses for financial advice)

Reporting Customization

  • Scheduled reports: Change timing, format, and recipients
  • Custom periods: Add quarterly, yearly, or custom date ranges
  • Categories: Modify auto-categorization rules for your spending patterns
  • Currency: Update formatting for your local currency

Advanced Features

  • Multi-user support: Add user identification for family/team use
  • Receipt photos: Extend workflow to process image receipts via OCR
  • Budgets: Add budget tracking and overspend alerts
  • Integrations: Connect to banks via Plaid or other financial APIs

Complete Package Included

When you download this template, you get everything needed for immediate implementation:

Ready-to-Use n8n Workflow

  • Fully configured nodes with descriptive names explaining each step
  • Color-coded sticky notes throughout the workflow explaining:
  • What each branch does (Reports/Transactions/Chat)
  • How the AI classification works
  • Database connection requirements
  • Error handling and troubleshooting tips

Comprehensive Documentation Bundle

  • Quick Start Guide: Get running in under 10 minutes
  • Detailed Setup Guide: Complete configuration walkthrough with screenshots
  • Branch Explanation Guide: Deep dive into each processing branch:
  • Branch 0: Reports & Analytics - SQL queries and formatting
  • Branch 1: Transaction Processing - AI parsing and database insertion
  • Branch 2: Financial Chat - AI responses and conversation handling

Built-in Workflow Documentation

  • Sticky notes at every major step explaining the logic
  • Node descriptions that clarify what each component does
  • Visual flow indicators showing message routing paths
  • Dependency callouts highlighting required credentials and connections

Technical Implementation Details

  • Database schema with complete SQL commands
  • API configuration examples for all external services
  • Troubleshooting checklist for common setup issues
  • Performance optimization recommendations

Bonus Resources

  • Example message templates to test each workflow branch
  • Sample data for testing reports and analytics
  • Customization recipes for common modifications
  • Integration patterns for extending functionality

Example Usage

Log Expenses:

  • Spent 1200 on rent this month
  • Paid 45 for gas at Shell
  • Coffee 5.50 at Starbucks

Log Income:

  • Received 5000 salary from Company ABC
  • Freelance payment 800 from Client XYZ

Generate Reports:

  • today's summary
  • show this week's expenses
  • compare March vs April spending
  • how much on food this month?

Expected Responses:

✅ Logged: expense | Rent | ₹1,200.00 | Landlord ✅ Logged: income | salary |₹12,000.00|company

📊 Today's Summary: Income: ₹0.00 Expenses: ₹1,245.50
Savings: -₹1,245.50

📈 March vs April: Expenses: ₹15,000 vs ₹12,500 (-16.7%) Top categories: Rent, Food, Transport

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Date and time

Type / Role
@n8n/n8n-nodes-langchain.toolCode - toolCode
Config choices
Version 1.2

Block 2 - Structured Output Parser

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.2

Block 3 - OpenRouter Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenRouter - lmChatOpenRouter
Config choices
Version 1

Block 4 - OpenRouter Chat Model1

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenRouter - lmChatOpenRouter
Config choices
Version 1

Block 5 - Calculator

Type / Role
@n8n/n8n-nodes-langchain.toolCalculator - toolCalculator
Config choices
Version 1

Block 6 - OpenRouter Chat Model3

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenRouter - lmChatOpenRouter
Config choices
Version 1

Block 7 - OpenRouter Chat Model4

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenRouter - lmChatOpenRouter
Config choices
Version 1

Block 8 - Postgres2

Type / Role
n8n-nodes-base.postgresTool - postgresTool
Config choices
Version 2.6

Block 9 - OpenRouter Chat Model5

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenRouter - lmChatOpenRouter
Config choices
Version 1

Block 10 - Calculator1

Type / Role
@n8n/n8n-nodes-langchain.toolCalculator - toolCalculator
Config choices
Version 1

Block 11 - Structured Output Parser2

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.2

Block 12 - OpenRouter Chat Model6

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenRouter - lmChatOpenRouter
Config choices
Version 1

Block 13 - Convert to File

Type / Role
n8n-nodes-base.convertToFile - convertToFile
Config choices
Version 1.1

Block 14 - Send Financial Response

Type / Role
n8n-nodes-base.whatsApp - whatsApp
Config choices
Version 1

Block 15 - Normal Conversation

Type / Role
n8n-nodes-base.whatsApp - whatsApp
Config choices
Version 1

Block 16 - Incoming WhatsApp Trigger

Type / Role
n8n-nodes-base.whatsAppTrigger - whatsAppTrigger
Config choices
Version 1

Block 17 - Message Intent Classifier

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.9

Block 18 - Route by Intent

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 19 - Parse & Validate Transaction

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.9

Block 20 - Split Transaction Lines

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 21 - Format Transaction JSON

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 22 - Validate Transaction Fields

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 23 - Insert Transaction into DB

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 24 - Build Confirmation Message

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.9

Showing the first 24 of 50 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow WhatsApp expense tracker with PostgreSQL database & AI-powered reports
Complexity advanced
Nodes 50
Categories Personal Productivity, AI Chatbot
Author Roshan Ramani
Published 17 May 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/4136/4136.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does WhatsApp expense tracker with PostgreSQL database & AI-powered reports do?

Track Personal Finances with WhatsApp and AI Assistant Transform your WhatsApp into a powerful personal finance command center. This AI powered workflow converts natural language messages into stru...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Personal Productivity, AI Chatbot use case.