Chat-based financial analysis of P&L and balance sheets with GPT-4 & PostgreSQL
Workflow preview
$20/month : Unlimited workflows
2500 executions/month
THE #1 IN WEB SCRAPING
Scrape any website without limits
HOSTINGER
Early Deal
DISCOUNT 20% Try free
DISCOUNT 20%
Self-hosted n8n
Unlimited workflows - from $4.99/mo
#1 hub for scraping, AI & automation
6000+ actors - $5 credits/mo
Important notice
This workflow is provided as-is. Please review and test before using in production.
Overview
π§Ύ Whoβs it for
This workflow is designed for finance teams, accountants, and data analysts π who want to interact with financial data from two PostgreSQL databases β one containing Profit & Loss data and another containing Balance Sheet data β using natural language chat.
Itβs perfect for those who need quick, AI-powered insights with the correct database automatically selected based on the question.
βοΈ How it works / What it does
- Chat Trigger π¬ β Starts the workflow when a chat message is received.
- AI Agent π€ β Processes the userβs question and decides:
- Profit & Loss DB β If the question is about revenue, costs, expenses, or profit.
- Balance Sheet DB β If the question is about assets, liabilities, or equity.
- PostgreSQL Query Nodes ποΈ β
- P_L_Reports queries the
financial_agent_pl_reportstable. - Balance_Sheets queries the
financial_agent_balancesheetstable.
- P_L_Reports queries the
- AI Model (OpenAI) π§ β Uses
gpt-4.1-nanoto interpret results and provide an easy-to-read answer. - Memory Buffer π β Keeps recent conversation context for a smoother chat experience.
- Table Output π β Always formats the results as a clean, readable table with two decimal precision.
π οΈ How to set up
Prepare Your Databases
- Feed your Profit & Loss and Balance Sheet data into PostgreSQL.
- Ensure the correct table structures are used:
- financial_agent_pl_reports β P&L data.
- financial_agent_balancesheets β Balance Sheet data.
Configure the PostgreSQL Nodes
- Add connection credentials for both databases.
- Link P_L_Reports and Balance_Sheets nodes to the correct tables.
Set Up the AI Agent
- Paste the provided system message into the AI Agent node (already configured in your workflow).
Connect the Nodes
- Ensure Chat Trigger β AI Agent β DB Nodes β AI Model connections match your workflow.
Deploy
- Save and activate the workflow.
- Start sending finance-related queries to test.
π Requirements
- n8n (latest version recommended)
- PostgreSQL databases with:
financial_agent_pl_reportstable (P&L data).financial_agent_balancesheetstable (Balance Sheet data).
- OpenAI API credentials with access to
gpt-4.1-nano. - Active Webhook/Chat Trigger for receiving queries.
π¨ How to customize
- Expand AI Instructions ποΈ β Add more rules in the system message for different data sources or formatting styles.
- Change AI Model π§ β Switch to a different OpenAI model for faster or more accurate results.
- Add More Databases ποΈ β Connect extra financial datasets, e.g., cash flow, sales analytics.
- Enhance Table Styling π β Use Markdown or HTML formatting for richer outputs.
- Refine Query Logic π β Modify filtering logic to better match your reporting needs.