AI Financial Statement Analyzer and Database Loader - n8n Workflow

Use this powerful n8n workflow to analyze bank statements (PDFs, Excel/CSV) using GPT-4o-mini, categorize transactions, and securely save summaries to a PostgreSQL database.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Financial Analysts needing fast, automated transaction categorization.

  • Developers integrating financial data processing into custom applications.

  • Automation Engineers looking for robust file handling and AI parsing in an n8n workflow.

  • Businesses that frequently process high volumes of varied document types (PDF, CSV) using n8n templates.

Overview

Manually processing and categorizing bank statement transactions across different file formats (PDF, Excel, CSV) is time-consuming and prone to errors. This specialized n8n workflow solves this by creating a robust ingestion pipeline. The automation handles complex tasks like detecting the file type, performing necessary data extraction (text from PDF or parsing from Excel), and then leveraging the power of an OpenAI n8n node to standardize and categorize the data into a clean JSON structure. This sophisticated n8n workflow ensures high accuracy in financial reporting and provides a clean summary stored directly in a PostgreSQL database for easy querying. This powerful approach eliminates manual effort and leverages the flexibility of the n8n automation platform.

How it Works

The entire process is initiated by an API call using the ‘Upload Statement’ n8n trigger (a Webhook node). This n8n trigger is configured to accept raw body file uploads.


  1. File Ingestion: The data moves to the ‘File Handler’ n8n node, which extracts essential metadata (like file type and name) from the binary input.

  2. Smart Routing: The ‘Check File Type’ n8n node (an If condition) intelligently routes the data. PDFs are sent to the ‘Extract PDF Text’ n8n node for text extraction, while Excel/CSV files proceed to the ‘Parse Excel/CSV’ n8n node.

  3. AI Extraction: Regardless of the source format, the extracted text or structured data converges at the ‘AI Data Extractor’ n8n node (OpenAI). This node utilizes GPT-4o-mini with a detailed system prompt to identify account information, extract all transactions, categorize them (groceries, dining, utilities, etc.), and format the output as a standardized JSON object.

  4. Data Processing: The ‘Process & Summarize’ n8n node then cleans the AI's output, validates amounts, calculates total income and total expenses, and generates a breakdown of spending by category.

  5. Persistence & Response: Finally, the processed data is simultaneously inserted into the PostgreSQL database using the ‘Save to Database’ n8n node and returned as a concise, successful JSON response via the ‘Send Response’ n8n node.

Installation Guide

To deploy this automated n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON data and import it directly into your n8n instance.

  2. OpenAI Credentials: Locate the ‘AI Data Extractor’ n8n node. You must configure or select existing OpenAI credentials (API Key) that support the specified model (gpt-4o-mini).

  3. PostgreSQL Credentials: Locate the ‘Save to Database’ n8n node. Configure a new PostgreSQL credential, ensuring your n8n instance can connect to your database.

  4. Database Setup: Ensure the target table bankstatements exists in your PostgreSQL database, configured with columns matching the data being inserted (e.g., accountnumber, totalincome, rawdata).

  5. Activate: Save and activate the n8n workflow. The Webhook URL provided by the ‘Upload Statement’ n8n trigger is now ready to receive POST requests containing bank statements.

Node Details

Upload Statement (Webhook n8n Trigger):
Function: Serves as the API entry point, configured to accept file uploads via POST request.
Key Configuration: Path is set to /upload-statement, and Response Mode is set to Response Node.
File Handler (Code n8n Node):
Function: Extracts binary file data and converts it into structured metadata (filename, mimeType) required for subsequent nodes.
Check File Type (If n8n Node):
Function: Directs the flow based on the file's MIME type. Checks specifically if the contentType contains application/pdf.
Extract PDF Text (Extract From File n8n Node):
Function: Extracts raw text content from PDF documents, preparing unstructured data for AI analysis.
Parse Excel/CSV (Spreadsheet File n8n Node):
Function: Converts structured spreadsheet files into an array of JSON objects.
AI Data Extractor (OpenAI n8n Node):
Function: The central intelligence. Uses GPT-4o-mini and a highly specific system prompt to perform complex financial data extraction and categorization from the document text/data. This key n8n node ensures data standardization.
Process & Summarize (Code n8n Node):
Function: Performs data validation, parses the AI's JSON output (which can sometimes be wrapped in markdown), calculates financial summaries (totals), and organizes the final data structure.
Save to Database (Postgres n8n Node):
Function: Persists the finalized, summarized financial data into a PostgreSQL table named bank_statements.
Send Response (Respond to Webhook n8n Node):
* Function: Provides immediate feedback to the API caller, including transaction counts and expense totals, ensuring a smooth external integration with this n8n workflow.

Related n8n Workflows

Free

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by
vinci-king-01
vinci-king-01

Featured*