How to Build an AI-Powered Bank Statement Automation with n8n: A Step-by-Step Guide
Jason Chau

Table of Contents
Automating Financial Data Translation and Storage with n8n: A Step-by-Step Guide
Tracking monthly spending to analyze my financial habits has always been a goal of mine. However, manually entering bank statements into Excel was painful. Now with AI, this repetitive task can be done quickly and easily. In this article, I will show you how to use n8n to convert uploaded bank and credit card statements and save the data to Google Sheets. This process includes using n8n nodes to extract information from PDFs, employing a simple AI tool to produce data in JSON format for easier handling, and finally storing the information in Google Sheets.
Problem
I want to track my spending on categories like entertainment, gas, groceries, and more. I also want to compare my spending against my income. I need a straightforward way to do this, preferably using AI, to save time and improve accuracy.
The Solution: n8n Workflow
The n8n workflow we’ll build consists of the following steps: you can find the workflow at the top of this page.
1. Upload Bank/Credit Card Statements: Users upload their statements.
2. Extract Data: Extract raw data from the statements PDF.
3. Transform and Process Data: Use AI models to transform and structure the data in JSON format.
4. Save to Google Sheets: Store the processed data in a Google Sheet.
Here’s how the workflow works in detail:
Step 1: Upload Bank/Credit Card Statements
The workflow starts when a user uploads a bank statement or credit card statement. These files are typically in PDF format in my case. In n8n, this can be done using a verities of triggers, a Webhook, File Upload or Telegram bot trigger node to receive the files. I use the n8n form with file upload, the simplest way to get started.
Step 2: Extract Data and Pre-process
Step 2.1: Convert PDF to text format
Once the files are uploaded, Extract from PDF node convert the statement into text format:
- For bank statements, the Extract Bank Statement
node processes the file.
- For credit card statements, the Extract CreditCard Statement
node processes the file.
Step 2.1: Run simple code to remove unrelated text, like terms and conditions from bank statements.
Even though models like GPT-4o-mini and others can handle images and large data, I want to reduce token usage and lower API costs. Removing irrelevant information will help the AI extract data more accurately.
Step 3: Transform and Structure Data
The extracted data goes to AI Agents for processing:
AI Agent: Handles bank statement data.
AI Agent1: Handles credit card statement data.
For the transformation, use Claude 3.5 Sonnet. I found it more accurate than GPT4o and GPT4o-mini.
Create a Tools Agent node and connect it to the Anthropic Chat Model. Obtain an Anthropic API key for access. Check the "Require Specific Output Format" option in the Tools Agent settings to link it to a structured output parser node.
javascript
// prompt
You are given a credit card statement. extract into the following format. ignore the posting date.
{
"type": "object",
"properties": {
"summary": {
"type": "object",
"properties": {
"opening_balance": { "type": "number", "description": "Balance at the start of the period" },
"total_deposits": { "type": "number", "description": "Sum of all deposits in the period" },
"total_withdrawals": { "type": "number", "description": "Sum of all withdrawals in the period" },
"closing_balance": { "type": "number", "description": "Balance at the end of the period" }
},
"required": ["opening_balance", "total_deposits", "total_withdrawals", "closing_balance"]
},
"activity_details": {
"type": "array",
"description": "List of individual transactions",
"items": {
"type": "object",
"properties": {
"date": { "type": "string", "format": "date", "description": "Transaction date (YYYY-MM-DD)" },
"description": { "type": "string", "description": "Short description of the transaction" },
"type": { "type": "string", "enum": ["Expense", "Payment"], "description": "Type of transaction" },
"amount": { "type": "number", "description": "Transaction amount" },
"balance_after": { "type": "number", "description": "Balance after this transaction" }
},
"required": ["date", "description", "type", "amount", "balance_after"]
}
}
},
"required": ["summary", "activity_details"]
}
{{ $json.text}}
Structured Output Parsing
The Structured Output Parser
nodes format the AI output into a structured JSON. It will ensure the data is correctly formatted for storage in Google Sheets. To use the structured output parser, the
json
//output parser format
{
"type": "object",
"properties": {
"summary": {
"type": "object",
"properties": {
"opening_balance": { "type": "number", "description": "Balance at the start of the period" },
"total_deposits": { "type": "number", "description": "Sum of all deposits in the period" },
"total_withdrawals": { "type": "number", "description": "Sum of all withdrawals in the period" },
"closing_balance": { "type": "number", "description": "Balance at the end of the period" }
},
"required": ["opening_balance", "total_deposits", "total_withdrawals", "closing_balance"]
},
"activity_details": {
"type": "array",
"description": "List of individual transactions",
"items": {
"type": "object",
"properties": {
"date": { "type": "string", "format": "date", "description": "Transaction date (YYYY-MM-DD)" },
"description": { "type": "string", "description": "Short description of the transaction" },
"type": { "type": "string", "enum": ["Expense", "Payment"], "description": "Type of transaction" },
"amount": { "type": "number", "description": "Transaction amount" },
"balance_after": { "type": "number", "description": "Balance after this transaction" }
},
"required": ["date", "description", "type", "amount", "balance_after"]
}
}
},
"required": ["summary", "activity_details"]
}
Step 4: Save to Google Sheets
The final step is to save the processed data into Google Sheets. to do that, you will need to enable Oauth2 in Google Cloud Platform, its free.
- Bank Statement Data/ Credit Card Data: Sent to Google Sheets
.
The Split Out
nodes ensure the data is properly formatted before being written to the sheets. Each row in the Google Sheet represents a transaction, with columns for date, description, amount, and other relevant fields.
Workflow Diagram
Here’s a visual representation of the workflow:
1. Bank Statement → Extract Bank Statement → AI Agent → Split Out → Google Sheets
2. Credit Card → Extract CreditCard Statement → Code → AI Agent → Code → Split Out → Google Sheets
Workflow improvement
Currently, the workflow only supports PDF files containing selectable text. However, it does not support scanned bank statements or receipts in image format. Since n8n does not provide a built-in OCR node, an external OCR tool is required for text extraction from images.
One possible solution is OCR.space, which offers a free plan with up to 25,000 requests per month, making it a suitable choice for personal use. Integrating an OCR tool into the workflow would enable processing a wider range of input format, making it flexible for more use case.
Additionally, n8n provides webhooks to trigger workflows, it could easily be integrated into a SaaS website.