Cash flow visibility makes or breaks business decisions. You need real-time insights, not spreadsheets you update manually every week. This n8n workflow creates an AI-powered agent that analyzes your financial data, generates actionable insights, and builds visual dashboards automatically. You'll learn how to connect your data sources, configure AI analysis, and deploy a production-ready cash flow monitoring system.
The Problem: Manual Cash Flow Analysis Wastes Time and Misses Patterns
Finance teams spend hours every week pulling data from multiple sources, calculating metrics, and creating reports. By the time you finish the analysis, the data is already outdated.
Current challenges:
- Manual data aggregation from bank accounts, payment processors, and accounting software
- Time-consuming calculations for runway, burn rate, and cash position
- No real-time visibility into cash flow trends
- Missed patterns that AI could identify instantly
- Inconsistent reporting formats across team members
Business impact:
- Time spent: 8-12 hours per week on manual reporting
- Delayed decision-making due to outdated data
- Risk of cash flow surprises that could have been predicted
- Inability to scale analysis as transaction volume grows
The Solution Overview
This n8n workflow creates an intelligent agent that monitors your cash flow data continuously. The agent pulls financial data from your sources, uses OpenAI's GPT-4 to analyze trends and generate insights, then creates visual dashboards in Google Sheets with charts and formatted reports.
The workflow runs on a schedule or webhook trigger, processes your latest transactions, calculates key metrics, and delivers formatted reports. You get AI-generated insights about spending patterns, revenue trends, and cash runway projections without touching a spreadsheet.
What You'll Build
This cash flow dashboard agent delivers comprehensive financial intelligence with minimal manual intervention.
| Component | Technology | Purpose |
|---|---|---|
| Data Source | Google Sheets / API Integration | Import transaction data from bank feeds or accounting software |
| AI Analysis Engine | OpenAI GPT-4 | Generate insights, identify trends, predict cash flow issues |
| Calculation Logic | n8n Function Nodes | Compute burn rate, runway, cash position metrics |
| Dashboard Creation | Google Sheets API | Build formatted reports with charts and conditional formatting |
| Alert System | Email / Slack Integration | Send notifications for critical cash flow events |
| Scheduling | n8n Cron Trigger | Automated daily or weekly report generation |
Key capabilities:
- Automated data ingestion from multiple financial sources
- AI-powered trend analysis and anomaly detection
- Real-time cash runway calculations
- Visual dashboard generation with charts
- Natural language insights about spending patterns
- Customizable alert thresholds for low cash warnings
- Historical comparison and forecasting
Prerequisites
Before starting, ensure you have:
- n8n instance (cloud or self-hosted version 1.0+)
- OpenAI API account with GPT-4 access
- Google account with Sheets API enabled
- Financial data source (bank CSV exports, accounting software API, or manual entry sheet)
- Basic JavaScript knowledge for customizing calculation logic
- Understanding of cash flow metrics (burn rate, runway, working capital)
Step 1: Set Up Your Data Source Connection
The workflow begins by connecting to your financial data. You'll configure n8n to pull transaction data from your source system.
Configure the data ingestion node:
- Add a Google Sheets node (or HTTP Request node for API-based sources)
- Authenticate with your Google account
- Select your source spreadsheet containing transaction data
- Map required fields: date, amount, category, description, type (inflow/outflow)
Node configuration for Google Sheets:
{
"authentication": "oAuth2",
"operation": "read",
"sheetName": "Transactions",
"range": "A:F",
"options": {
"valueRenderMode": "FORMATTED_VALUE"
}
}
Why this works:
The workflow treats your spreadsheet as a database, pulling all transaction records for analysis. Using FORMATTED_VALUE ensures dates and currency are parsed correctly. This approach works whether you're manually entering transactions or using automated bank feeds that export to Sheets.
Data structure requirements:
Your source sheet must include these columns:
- Date (MM/DD/YYYY format)
- Amount (numeric, negative for expenses)
- Category (text label like "Payroll", "Revenue", "Software")
- Description (transaction details)
- Type (either "Income" or "Expense")
Step 2: Process and Calculate Cash Flow Metrics
After ingesting data, the workflow calculates essential financial metrics using Function nodes.
Configure the calculation engine:
- Add a Function node named "Calculate Metrics"
- Insert JavaScript to compute burn rate, runway, and cash position
- Add date range filtering for current period analysis
- Calculate month-over-month growth rates
Function node code:
// Calculate key cash flow metrics
const transactions = $input.all();
const today = new Date();
const thirtyDaysAgo = new Date(today.getTime() - (30 * 24 * 60 * 60 * 1000));
// Filter to last 30 days
const recentTransactions = transactions.filter(t => {
const txDate = new Date(t.json.date);
return txDate >= thirtyDaysAgo && txDate <= today;
});
// Calculate totals
const totalIncome = recentTransactions
.filter(t => t.json.type === 'Income')
.reduce((sum, t) => sum + parseFloat(t.json.amount), 0);
const totalExpenses = recentTransactions
.filter(t => t.json.type === 'Expense')
.reduce((sum, t) => sum + Math.abs(parseFloat(t.json.amount)), 0);
const netCashFlow = totalIncome - totalExpenses;
const monthlyBurnRate = totalExpenses;
const currentCash = 150000; // Pull from bank balance API or manual input
const runway = currentCash / monthlyBurnRate;
return [{
json: {
period: '30 days',
totalIncome,
totalExpenses,
netCashFlow,
monthlyBurnRate,
currentCash,
runwayMonths: runway.toFixed(1),
analysisDate: today.toISOString()
}
}];
Why this approach:
The calculation logic separates income from expenses, then computes the burn rate (monthly spending) and runway (months until cash runs out). This gives you the two most critical metrics for business survival. The 30-day window provides recent trends without noise from older data.
Variables to customize:
thirtyDaysAgo: Change to 60 or 90 days for longer trend analysiscurrentCash: Connect to your bank API for real-time balance- Category-specific burn rates: Add groupBy logic to analyze spending by department
Step 3: Generate AI-Powered Insights
The OpenAI node analyzes your calculated metrics and generates natural language insights.
Configure the AI analysis node:
- Add an OpenAI node after the calculation step
- Set the model to "gpt-4" for best analysis quality
- Create a structured prompt with your metrics
- Configure temperature to 0.3 for consistent, factual outputs
OpenAI node configuration:
{
"resource": "chat",
"model": "gpt-4",
"messages": {
"values": [
{
"role": "system",
"content": "You are a financial analyst specializing in cash flow analysis. Provide concise, actionable insights based on the data provided."
},
{
"role": "user",
"content": "Analyze this cash flow data and provide 3-5 key insights:
Total Income: ${{$json.totalIncome}}
Total Expenses: ${{$json.totalExpenses}}
Net Cash Flow: ${{$json.netCashFlow}}
Monthly Burn Rate: ${{$json.monthlyBurnRate}}
Current Cash: ${{$json.currentCash}}
Runway: {{$json.runwayMonths}} months
Provide: 1) Overall health assessment, 2) Biggest concerns, 3) Specific recommendations"
}
]
},
"options": {
"temperature": 0.3,
"maxTokens": 500
}
}
Why this works:
GPT-4 excels at pattern recognition in financial data. By providing structured metrics rather than raw transactions, you get focused insights about trends and risks. The low temperature (0.3) ensures consistent, factual analysis rather than creative interpretations. The system prompt establishes the AI's role as a financial analyst, improving output quality.
Prompt engineering tips:
- Include historical context by passing previous period metrics
- Ask for specific formats (bullet points, numbered lists) for easier parsing
- Request quantified recommendations ("reduce spending by X%") not vague advice
- Add constraints like "focus on top 3 expense categories"
Step 4: Build the Visual Dashboard
The workflow creates a formatted Google Sheets dashboard with your metrics and AI insights.
Configure dashboard generation:
- Add a Google Sheets node set to "Append or Update" operation
- Create a template sheet with predefined chart areas
- Use the Sheets API to write metrics to specific cells
- Add conditional formatting rules for visual alerts
Dashboard structure:
| Section | Content | Location |
|---|---|---|
| Summary Metrics | Current cash, runway, burn rate | Cells A1:C4 |
| AI Insights | GPT-4 analysis text | Cells A6:C15 |
| Income Chart | 30-day income trend line | Chart object 1 |
| Expense Breakdown | Category pie chart | Chart object 2 |
| Cash Flow Trend | Net cash flow over time | Chart object 3 |
Google Sheets node configuration:
{
"operation": "update",
"sheetName": "Dashboard",
"range": "A1:C4",
"options": {
"valueInputMode": "USER_ENTERED",
"data": [
["Metric", "Value", "Status"],
["Current Cash", "={{$json.currentCash}}", "={{IF($json.runwayMonths<3,'⚠️','✅')}}"],
["Monthly Burn", "={{$json.monthlyBurnRate}}", ""],
["Runway (months)", "={{$json.runwayMonths}}", "={{IF($json.runwayMonths<6,'🔴','🟢')}}"]
]
}
}
Conditional formatting rules:
- Runway < 3 months: Red background, bold text
- Runway 3-6 months: Yellow background
- Runway > 6 months: Green background
- Negative cash flow: Red text for net cash flow cell
Why this structure:
The dashboard separates high-level metrics (top section) from detailed analysis (charts below). Status indicators use emoji for instant visual recognition. The layout works on mobile devices and prints cleanly for board meetings.
Workflow Architecture Overview
This workflow consists of 12 nodes organized into 4 main sections:
- Data ingestion (Nodes 1-3): Pulls transaction data from Google Sheets, validates data structure, filters to relevant date range
- Processing logic (Nodes 4-6): Calculates cash flow metrics, aggregates by category, computes growth rates
- AI analysis (Nodes 7-8): Sends metrics to OpenAI, parses insights, formats for dashboard
- Output delivery (Nodes 9-12): Updates Google Sheets dashboard, sends Slack alert if runway < 6 months, logs execution results
Execution flow:
- Trigger: Schedule node runs daily at 6 AM
- Average run time: 15-25 seconds depending on transaction volume
- Key dependencies: Google Sheets API, OpenAI API, Slack webhook (optional)
Critical nodes:
- Function "Calculate Metrics": Handles all financial calculations, must be updated if you add new metric types
- OpenAI Chat: Processes insights, requires GPT-4 access for best results
- Google Sheets "Update Dashboard": Writes formatted data, uses cell references for chart data sources
The complete n8n workflow JSON template is available at the bottom of this article.
Key Configuration Details
OpenAI Integration
Required fields:
- API Key: Your OpenAI API key from platform.openai.com
- Model: gpt-4 (gpt-3.5-turbo works but provides lower quality insights)
- Max Tokens: 500 (increase to 1000 for more detailed analysis)
Common issues:
- Using gpt-3.5-turbo → Results in generic, less actionable insights
- Always use gpt-4 for financial analysis
- Temperature > 0.5 → Inconsistent outputs, stick to 0.3 or lower
Google Sheets API Setup
Authentication steps:
- Enable Google Sheets API in Google Cloud Console
- Create OAuth 2.0 credentials
- Add credentials to n8n (Settings → Credentials → Google Sheets OAuth2)
- Authorize access to your Google account
Critical settings:
- Value Render Mode: "FORMATTED_VALUE" (preserves currency formatting)
- Value Input Mode: "USER_ENTERED" (allows formulas in cells)
- Always specify exact ranges (A1:C4) not entire columns for faster execution
Error handling configuration:
Add an Error Trigger node connected to a Slack notification:
{
"errorWorkflow": true,
"triggerOn": "internalError",
"message": "Cash Flow Dashboard failed: {{$json.error.message}}"
}
This catches API failures, data validation errors, or calculation issues and alerts you immediately.
Testing & Validation
Test each component independently:
Data ingestion: Run manually, verify all transactions load correctly
- Check for null values in required fields
- Validate date parsing (common issue with international formats)
- Confirm amount fields are numeric
Calculation logic: Add a "Send to Webhook" node after calculations
- Inspect JSON output for correct metric values
- Verify burn rate matches manual calculation
- Check runway calculation: currentCash / monthlyBurnRate
AI insights: Review OpenAI responses for quality
- Ensure insights reference specific numbers from your data
- Verify recommendations are actionable
- Check for hallucinations (AI making up data points)
Dashboard output: Open Google Sheets after workflow runs
- Confirm all cells update with new values
- Check charts refresh with latest data
- Verify conditional formatting applies correctly
Common troubleshooting:
| Issue | Cause | Solution |
|---|---|---|
| "Invalid date format" error | Google Sheets date parsing | Convert dates to ISO format in Function node |
| OpenAI timeout | Large prompt size | Reduce transaction detail, send only aggregated metrics |
| Charts not updating | Static data ranges | Use dynamic ranges: =Dashboard!A2:A instead of A2:A30 |
| Negative runway | Income classified as expense | Check transaction type field mapping |
Production Deployment Checklist
| Area | Requirement | Why It Matters |
|---|---|---|
| Error Handling | Retry logic with exponential backoff on API calls | Prevents workflow failure from temporary API outages |
| Monitoring | Webhook health check to external monitoring service | Detect silent failures within 5 minutes vs discovering days later |
| Documentation | Inline comments in Function nodes explaining calculations | Reduces modification time from 2 hours to 20 minutes |
| Data Backup | Daily export of dashboard to separate sheet | Prevents data loss if dashboard is accidentally modified |
| Access Control | Restrict Google Sheets edit access to workflow service account | Prevents manual edits that break chart references |
| Rate Limiting | Add Wait node between API calls if processing >1000 transactions | Avoids hitting OpenAI rate limits (500 requests/min) |
Production configuration changes:
- Increase Function node timeout from 10s to 30s for large datasets
- Add a Set node to store previous period metrics for trend comparison
- Enable workflow execution history (Settings → Workflow → Save Execution Data)
- Set up Slack alerts for runway < 3 months (critical threshold)
Real-World Use Cases
Use Case 1: SaaS Startup Monthly Reporting
- Industry: B2B SaaS
- Scale: 200-500 transactions/month, $50K-$200K MRR
- Modifications needed: Add MRR calculation node, integrate Stripe API for subscription data, include churn rate in AI analysis
Use Case 2: E-commerce Cash Flow Forecasting
- Industry: E-commerce / DTC brand
- Scale: 2,000+ transactions/month, seasonal revenue
- Modifications needed: Add inventory cost tracking, connect Shopify API, include 90-day forecast based on historical seasonality patterns
Use Case 3: Agency Profitability Dashboard
- Industry: Marketing/consulting agency
- Scale: 50-100 transactions/month, project-based revenue
- Modifications needed: Add project-level profitability calculations, integrate time tracking data, include billable hours analysis
Use Case 4: Multi-Entity Holding Company
- Industry: Investment/holding company
- Scale: Multiple subsidiaries, consolidated reporting
- Modifications needed: Add entity-level filtering, create separate dashboards per subsidiary, roll up to consolidated view with inter-company eliminations
Customizing This Workflow
Alternative Integrations
Instead of Google Sheets:
- Airtable: Better for complex data relationships - requires 3 node changes (replace Google Sheets nodes with Airtable nodes)
- PostgreSQL/Supabase: Better for high transaction volume (>10K/month) - swap Google Sheets nodes with Postgres nodes, add connection pooling
- QuickBooks API: Direct accounting software integration - replace data ingestion with QuickBooks node, map chart of accounts to categories
Workflow Extensions
Add automated forecasting:
- Add a Function node with linear regression for 90-day cash projection
- Connect to Google Sheets to write forecast data
- Include forecast vs actual comparison in AI analysis
- Nodes needed: +3 (Function for regression, Sheets update, comparison logic)
Scale to handle more data:
- Replace single Function node with batch processing (process 1000 transactions at a time)
- Add Redis/Supabase caching layer for previously calculated metrics
- Implement incremental updates (only process new transactions since last run)
- Performance improvement: 10x faster for >5,000 transactions, reduces API costs by 80%
Add predictive alerts:
- Train a simple ML model on historical data to predict cash shortfalls
- Add Python node with scikit-learn for anomaly detection
- Send proactive alerts 2-3 weeks before projected cash issues
- Complexity: Medium (requires Python knowledge, +8 nodes)
Integration possibilities:
| Add This | To Get This | Complexity |
|---|---|---|
| Slack integration | Daily summary in #finance channel | Easy (2 nodes) |
| Stripe API | Automatic MRR and churn tracking | Medium (5 nodes) |
| QuickBooks sync | Eliminate manual transaction entry | Medium (6 nodes) |
| Plaid integration | Direct bank account connections | Hard (10+ nodes, requires Plaid account) |
| Power BI connector | Executive dashboards with drill-downs | Medium (8 nodes) |
Customization for different business models:
Subscription businesses:
Add these calculations:
- Monthly Recurring Revenue (MRR)
- Customer Lifetime Value (LTV)
- LTV:CAC ratio
- Churn rate impact on runway
Project-based businesses:
Add these calculations:
- Accounts receivable aging
- Project profitability by client
- Billable utilization rate
- Cash collection timeline
E-commerce:
Add these calculations:
- Inventory turnover rate
- Days inventory outstanding
- Gross margin by product category
- Marketing spend ROI
Get Started Today
Ready to automate your cash flow analysis?
- Download the template: Scroll to the bottom of this article to copy the complete n8n workflow JSON
- Import to n8n: Go to Workflows → Import from URL or File, paste the JSON
- Configure your services: Add your API credentials for OpenAI and Google Sheets (Settings → Credentials)
- Customize calculations: Update the Function node with your specific metrics and thresholds
- Test with sample data: Run the workflow manually with 30 days of transaction data to verify outputs
- Deploy to production: Set your schedule (daily at 6 AM recommended) and activate the workflow
First-run checklist:
- Verify all nodes show green checkmarks after test execution
- Open your Google Sheets dashboard and confirm data appears
- Review AI insights for relevance and accuracy
- Set up Slack alerts for critical thresholds
- Document any custom calculations you added
Need help customizing this workflow for your specific business model or integrating with your accounting software? Schedule an intro call with Atherial at https://atherial.ai/contact.
Complete n8n Workflow JSON Template
{
"name": "Cash Flow Dashboard Agent",
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"field": "cronExpression",
"expression": "0 6 * * *"
}
]
}
},
"name": "Schedule Daily",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [250, 300],
"typeVersion": 1
},
{
"parameters": {
"authentication": "oAuth2",
"operation": "read",
"sheetName": "Transactions",
"range": "A:F",
"options": {
"valueRenderMode": "FORMATTED_VALUE"
}
},
"name": "Get Transactions",
"type": "n8n-nodes-base.googleSheets",
"position": [450, 300],
"typeVersion": 3
},
{
"parameters": {
"functionCode": "const transactions = $input.all();
const today = new Date();
const thirtyDaysAgo = new Date(today.getTime() - (30 * 24 * 60 * 60 * 1000));
const recentTransactions = transactions.filter(t => {
const txDate = new Date(t.json.date);
return txDate >= thirtyDaysAgo && txDate <= today;
});
const totalIncome = recentTransactions
.filter(t => t.json.type === 'Income')
.reduce((sum, t) => sum + parseFloat(t.json.amount), 0);
const totalExpenses = recentTransactions
.filter(t => t.json.type === 'Expense')
.reduce((sum, t) => sum + Math.abs(parseFloat(t.json.amount)), 0);
const netCashFlow = totalIncome - totalExpenses;
const monthlyBurnRate = totalExpenses;
const currentCash = 150000;
const runway = currentCash / monthlyBurnRate;
return [{
json: {
period: '30 days',
totalIncome,
totalExpenses,
netCashFlow,
monthlyBurnRate,
currentCash,
runwayMonths: runway.toFixed(1),
analysisDate: today.toISOString()
}
}];"
},
"name": "Calculate Metrics",
"type": "n8n-nodes-base.function",
"position": [650, 300],
"typeVersion": 1
},
{
"parameters": {
"resource": "chat",
"model": "gpt-4",
"messages": {
"values": [
{
"role": "system",
"content": "You are a financial analyst specializing in cash flow analysis. Provide concise, actionable insights."
},
{
"role": "user",
"content": "Analyze this cash flow data and provide 3-5 key insights:
Total Income: ${{$json.totalIncome}}
Total Expenses: ${{$json.totalExpenses}}
Net Cash Flow: ${{$json.netCashFlow}}
Monthly Burn Rate: ${{$json.monthlyBurnRate}}
Current Cash: ${{$json.currentCash}}
Runway: {{$json.runwayMonths}} months
Provide: 1) Overall health assessment, 2) Biggest concerns, 3) Specific recommendations"
}
]
},
"options": {
"temperature": 0.3,
"maxTokens": 500
}
},
"name": "Generate AI Insights",
"type": "n8n-nodes-base.openAi",
"position": [850, 300],
"typeVersion": 1
},
{
"parameters": {
"operation": "update",
"sheetName": "Dashboard",
"range": "A1:C10",
"options": {
"valueInputMode": "USER_ENTERED"
}
},
"name": "Update Dashboard",
"type": "n8n-nodes-base.googleSheets",
"position": [1050, 300],
"typeVersion": 3
}
],
"connections": {
"Schedule Daily": {
"main": [[{"node": "Get Transactions", "type": "main", "index": 0}]]
},
"Get Transactions": {
"main": [[{"node": "Calculate Metrics", "type": "main", "index": 0}]]
},
"Calculate Metrics": {
"main": [[{"node": "Generate AI Insights", "type": "main", "index": 0}]]
},
"Generate AI Insights": {
"main": [[{"node": "Update Dashboard", "type": "main", "index": 0}]]
}
}
}
Copy this JSON and import it into your n8n instance to get started. Remember to configure your API credentials and customize the calculation logic for your specific business needs.
