Chat-based financial analysis of P&L and balance sheets with GPT-4 & PostgreSQL
π§Ύ 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 con...
Template notes
π§Ύ 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 1. Chat Trigger π¬ β Starts the workflow when a chat message is received. 2. 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. 3. PostgreSQL Query Nodes ποΈ β - PLReports queries the financialagentplreports table. - BalanceSheets queries the financialagentbalancesheets table. 4. AI Model (OpenAI) π§ β Uses gpt-4.1-nano to interpret results and provide an easy-to-read answer. 5. Memory Buffer π β Keeps recent conversation context for a smoother chat experience. 6. Table Output π β Always formats the results as a clean, readable table with two decimal precision.
---
π οΈ How to set up 1. Prepare Your Databases - Feed your Profit & Loss and Balance Sheet data into PostgreSQL. - Ensure the correct table structures are used: - financialagentplreports β P&L data. - financialagentbalancesheets β Balance Sheet data.
2. Configure the PostgreSQL Nodes - Add connection credentials for both databases. - Link PLReports and BalanceSheets nodes to the correct tables.
3. Set Up the AI Agent - Paste the provided system message into the AI Agent node (already configured in your workflow).
4. Connect the Nodes - Ensure Chat Trigger β AI Agent β DB Nodes β AI Model connections match your workflow.