Automate Financial Performance Analysis with n8n & MySQL

This workflow automates monthly financial performance reporting by integrating MySQL data queries with n8n automation. It processes cost center budgets, project statuses, and employee data to deliver detailed, AI-analyzed business insights and HTML email reports.
mySql
microsoftOutlook
agent
+10
Workflow Identifier: 1227
NODES in Use: Schedule Trigger, Date & Time, Code, MySQL, Filter, Split in Batches, HTML, Merge, Microsoft Outlook, Wait, Code, Business Performance AI Agent (Analyst), Calculator

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What this workflow does

This workflow automates monthly financial reports based on company data.
It solves the problem of manual, slow, and error-prone financial report preparation.
The result is fast, accurate reports with deep analysis sent by email automatically every month.

The workflow fetches, processes and analyzes cost centers, budgets, projects, and employee financial data.
It then uses AI to write summaries and sends a full report to managers.


Who should use this workflow

This workflow is useful for finance managers and accountants with lots of financial data to report monthly.
It helps any company using MySQL with financial tables wanting to save time and improve accuracy.

Anyone who wants to get AI-generated analysis and automated email reports will find it very helpful.


Tools and services used

  • n8n: for workflow automation and connecting all parts.
  • MySQL Database: storing ERPNext or similar financial data.
  • Google Gemini AI: to generate text analysis from financial data.
  • Microsoft Outlook: for sending automated email reports.

Beginner step-by-step: How to build this in n8n

Step 1: Download and import the workflow

  1. Download the workflow file using the Download button on this page.
  2. Go to the n8n editor already open in your browser.
  3. Use the menu option “Import from File” and select the downloaded workflow.

Step 2: Configure credentials and settings

  1. Add your MySQL database credentials in the MySQL nodes.
  2. Connect your Microsoft Outlook account in the Microsoft Outlook node.
  3. Set up your Google Gemini AI API key in the AI node.
  4. Update cost center IDs, email addresses, or SQL table names if your setup differs.

Step 3: Test and activate

  1. Run the workflow manually once to check if all nodes work without errors.
  2. Check the email inbox to confirm report receipt.
  3. Fix any errors using debug logs shown by n8n.
  4. Switch ON the Schedule Trigger node to run automatically every 5th day monthly.

Workflow Inputs, Processing Steps, and Outputs

Inputs

  • Monthly trigger date (5th of each month).
  • Financial data from MySQL ERPNext tables: cost centers, budgets, GL entries, projects, employees.
  • Credentials for MySQL, Outlook, and Google Gemini AI.

Processing Steps

  • Calculate previous month and year dynamically for reporting.
  • Fetch active cost centers with budgets for the period.
  • Loop through each cost center to gather YTD and previous month budget vs actual data.
  • Retrieve vertical department profit and loss data for deeper breakdown.
  • Query project data to calculate WIP, contract, invoice percentages.
  • Get employee counts and new hire info.
  • Use Code nodes to format all data into HTML tables.
  • Merge all formatted tables into one stream.
  • Generate a styled, structured full HTML report with headings and CSS.
  • Send HTML content to Google Gemini AI chat node for analysis and executive summary.
  • Clean AI output, prepare email content and subject.
  • Send the email report with Microsoft Outlook node.
  • Add wait/delay between processing for scalability.

Outputs

  • The final output is a detailed, AI-analyzed, and formatted HTML financial report.
  • Managers receive the report by email automatically every month.

Edge cases and failure handling

If MySQL queries fail with unknown column errors, check SQL table and column names.
Make sure schema matches what the workflow expects.

Authentication errors in Outlook require verifying credentials and permissions.
Update multi-factor authentication or app passwords.

AI node may return incomplete or broken HTML if input data is malformed.
Use debug mode to verify input HTML; clean HTML before sending to AI.


Customization ideas

  • Switch from a single cost center to multiple by changing the Filter node.
  • Adjust email recipients or add multiple addresses in the Outlook node.
  • Add more financial metrics by editing SQL queries for more detail.
  • Change the report HTML style or add branding logos in the final Code node.
  • Change the Schedule Trigger timing to match different reporting deadlines.

Deployment guide

Turn ON the Schedule Trigger node to activate monthly runs.
Monitor workflow logs for errors after the first few runs.

Adjust wait times if processing many cost centers to avoid overload.
Use stable hosting or consider self-host n8n for better control.


Summary

✓ Saves over 10 hours monthly by automating recurring financial reports.
✓ Eliminates manual SQL queries and reduces errors.
✓ Provides clear, easy-to-understand HTML reports with AI-generated analysis.
✓ Sends reliable reports automatically to key business managers by email.
✓ Scales easily to any number of cost centers or departments.


Frequently Asked Questions

Yes, the workflow can run with PostgreSQL if SQL queries are adjusted for PostgreSQL syntax and schema.
Yes, Google Gemini API usage consumes credits, so monitor quota when generating large reports.
Check that SQL queries match the exact database table and column names used in the financial schema.
Turn ON the Schedule Trigger node set for the 5th day monthly to enable automatic runs.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free