WhatsApp Financial Agent for Multi-Input Expense Tracking - n8n Workflow

Use this advanced n8n workflow to track expenses sent via WhatsApp text, image (receipt OCR), or audio. This powerful n8n template integrates AI agents, LangChain, and Postgres for seamless financial management.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Individuals or small teams seeking a simple, chat-based method for tracking daily expenditures.
Users looking for advanced n8n templates that combine conversational AI (LLMs) with database operations.
Developers needing a comprehensive example of an n8n workflow integrating WhatsApp, OCR, Transcription, and LangChain agents.
Businesses requiring an easy-to-use, multi-input data capture system powered by n8n nodes.

Overview

This is an incredibly powerful and versatile n8n workflow designed to transform your WhatsApp conversations into a functional financial management tool. It solves the friction of traditional expense tracking apps by allowing users to log expenses using whatever format is easiest at the moment—be it a quick text message, a photo of a receipt, or a voice note.

The core value of this n8n template lies in its multi-modal processing capabilities. An incoming message triggers the n8n workflow, which first authenticates the user and then routes the request based on intent (logging a transaction, requesting a summary, or simple chat). For media inputs, the n8n nodes handle downloading, transcription (for audio), or OCR (for images/receipts). All parsed data is then validated and securely stored in a Postgres database. This sophisticated n8n solution demonstrates best practices for using LangChain agents within an n8n workflow environment.

How it Works

The entire n8n workflow is initiated by the Incoming WhatsApp Trigger n8n node.


  1. Incoming Message & User Check: The n8n trigger captures the message. The flow checks the message type (text/media) and then runs a query against Postgres to see if the sender's profile exists. If not, a new user is created.

  2. Intent Classification: A LangChain AI agent (Message Intent Classifier) uses the message content to determine the user's goal: Report Request, Expense Log (Text), Expense Log (Media), or Casual Chat. The n8n workflow then routes the execution using the Route by Intent switch n8n node.

  3. Handling Media Inputs (Image/Audio):

Image Route: The n8n workflow downloads the image, converts it to base64, and sends it to the Gemini API (Run OCR on Image) for text extraction (OCR).
Audio Route: The n8n workflow downloads the audio file, sends it to Deepgram (Transcribe Audio by deepgram) for transcription, turning the voice note into text.

  1. Transaction Parsing: Dedicated LangChain Agents (Parse & Validate Transaction family of n8n nodes) take the extracted or raw text input. They are instructed to rigorously parse the financial data into a structured JSON format (amount, category, description).

  2. Database Insertion: The structured data is handled by code n8n nodes for final formatting and validation before the Insert Transaction into DB1 (Postgres n8n node) commits the record.

  3. Reporting & Confirmation: For successful expense logs, a final LangChain Agent generates a friendly confirmation message, which is sent back to the user via a WhatsApp n8n node. For report requests, a complex sub-workflow uses AI to build a Postgres SQL query, executes it, summarizes the results, and sends the resulting summary back via WhatsApp. This full lifecycle is managed efficiently by the core n8n platform.

Installation Guide


  1. Import the n8n Workflow: Copy the provided JSON data and import it into your n8n instance via the Workflows section (New > Import from JSON).

  2. Set Up Credentials:

WhatsApp: You will need credentials for the Incoming WhatsApp Trigger and the various outbound WhatsApp n8n nodes (ensure you have the necessary webhook configuration set up with your WhatsApp provider, e.g., Meta Cloud API).
AI Services: Provide credentials for OpenAI (used by the LangChain Agent n8n nodes), and external services like Gemini (for OCR) and Deepgram (for audio transcription) within the respective HTTP Request n8n nodes.
* Database: Configure the Postgres credential required by the Fetch User Profile from Postgres and Insert Transaction into DB1 n8n nodes. Ensure your database schema is correctly set up to handle users and transaction records as expected by the Code and Postgres n8n node configurations.

  1. Activate the n8n workflow: Once all credentials are set and the n8n nodes are configured, activate the n8n workflow to start processing live messages.

Node Details

Incoming WhatsApp Trigger: The initial n8n trigger. Listens for incoming messages to start the entire n8n workflow.
LangChain Agent (Message Intent Classifier): Uses an LLM (via an OpenAI Chat Model n8n node) to categorize the incoming user request into predefined actions (e.g., Log Expense, Get Report).
Postgres n8n node (User/DB Ops): Used to check user existence and insert new user profiles or transaction records into the database. Key for persistent data storage in this n8n workflow.
HTTP Request n8n node (Run OCR on Image): Configured to interface with a service like the Gemini API, it extracts text from attached receipt images. This is a critical custom step in the multi-modal n8n node chain.
HTTP Request n8n node (Transcribe Audio by deepgram): Downloads and sends audio files for accurate transcription, transforming spoken expense reports into actionable text data.
LangChain Agent (Parse & Validate Transaction): Several versions of this powerful n8n node exist, tailored to clean and structure data derived from raw text, OCR output, or audio transcription before committing it to the database.
Code n8n node (Transform Custom Query for Postgres): Executes custom JavaScript logic to sanitize and finalize the AI-generated SQL query before it is run against the Postgres database, ensuring security and format correctness within the n8n template.
WhatsApp n8n node (Send Financial Response1): Used at the end of the transaction logging path to send confirmation or error messages back to the user, completing the loop of this complex n8n workflow.

Related n8n Workflows

Paid

Nodes: 16 Nodes
Updated: December 26 2025
View all
Created by

I build robust, error-handled n8n automations—enhanced with AI—to simplify email, social, and CRM tasks. You can explore my published templates, like the WhatsApp Expense Tracker, directly in the n8n community. I’m endlessly curious—experimenting daily with new nodes, AI integrations (LangChain, OpenRouter), and workflow patterns to push what's possible in n8n.

Featured*