Financial Report Generation and Comparison using DeepSeek AI - n8n Workflow

Use this advanced n8n workflow to automate multi-period financial analysis. An n8n AI agent extracts data from Google Sheets, compares current, monthly, and yearly performance, and summarizes it instantly. Explore these powerful n8n templates.

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 period-over-period comparisons.
• Accountants looking to generate summary reports without manual spreadsheet manipulation.
• n8n users seeking advanced examples of AI Agents integrating external tools and custom code.
• Businesses utilizing Google Sheets as their primary ledger or reporting data source.

Overview

Manually comparing financial performance across different time periods (current month vs. last month vs. last year) can be tedious and prone to error. This powerful n8n workflow completely automates this complex reporting task.

It leverages a conversational AI Agent powered by DeepSeek and LangChain, enabling users to request a report via a simple chat interface. The n8n agent then intelligently determines the necessary date ranges and executes a dedicated data processing sub-workflow (acting as an external tool). This sub-workflow queries Google Sheets, uses custom JavaScript (a powerful n8n node) to filter, pivot, and aggregate revenue/expense data for the three defined cycles. The final, structured data is returned to the AI Agent, which performs the final evaluation and comparison, providing a professional summary report.

This specialized n8n workflow demonstrates the pinnacle of low-code automation, combining the power of LLMs with robust data manipulation capabilities. It serves as an excellent reference for creating custom n8n templates for finance operations.

How it Works

This comprehensive n8n workflow operates in two main phases: the AI Query Phase and the Data Processing Phase.

1. AI Query Phase (Main Workflow):
The automation is initiated by the When chat message received n8n trigger, typically from a connected chat application (like Telegram or Slack).
The input message is fed to the AI Agent, which utilizes the DeepSeek Chat Model for its intelligence and Window Buffer Memory1 for context.
The Agent's primary instruction is to act as an accountant, generating the required start and end dates for the current period, previous month, and previous year.
The Agent executes the Call n8n Workflow Tool, passing the six dynamically generated date parameters to the data-intensive sub-workflow.

2. Data Processing Phase (Sub-Workflow):
The sub-workflow starts with the When Executed by Another Workflow n8n trigger, capturing the required dates.
The Get revenual from google sheet n8n node downloads the raw financial transaction data from the connected Google Sheet.
The data is then simultaneously routed through three specialized Code n8n node instances (Pivot current circle, Pivot last circle, Pivot last year cirle). These custom scripting nodes filter the raw data based on the specific date range assigned to each pivot, normalize transaction categories, and calculate the total amount per category for that period.
Multiple Set and Aggregate n8n nodes (Format data current circle, Sum current circle, etc.) are used to structure and combine the aggregated data with its contextual date information.


  • Finally, the Collect all and Change title out come n8n nodes merge the three distinct period summaries (Current, Last Month, Last Year) into a single JSON object under the key data doanh thu, which is sent back to the AI Agent for final synthesis and response.

Installation Guide

To deploy this powerful n8n template, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON data and paste it into your n8n instance via the 'Import from JSON' option.

  2. DeepSeek Credentials: Locate the DeepSeek Chat Model n8n node and set up or select your DeepSeek API credentials. This requires an active DeepSeek API key.

  3. Google Sheets Credentials: Locate the Get revenual from google sheet n8n node. Connect your Google Sheets OAuth2 account. Ensure this account has read access to the target spreadsheet (Data Bao cao kinh doanh).

  4. Configure Sub-Workflow ID: The Call n8n Workflow Tool n8n node must be linked to the data processing portion of the flow. If the entire JSON was imported as one unit, the ID should be correctly linked. Verify that the 'Workflow ID' parameter points to the trigger ID of the 'When Executed by Another Workflow' part (indicated by the 4ASVA3i1vaFwj20h placeholder in the original setup).

  5. Activate and Test: Activate the main n8n workflow. Use the connected chat application (When chat message received n8n trigger) to send a request, initiating the AI analysis.

Node Details

When chat message received (n8n trigger): The starting point of the main n8n workflow. Listens for incoming chat messages to trigger the AI analysis.
AI Agent (LangChain): The core intelligence. It coordinates the conversation, uses the DeepSeek model, maintains memory, and decides when to use the sub-workflow tool. System instructions enforce the role of a company accountant.
DeepSeek Chat Model: The Large Language Model (LLM) providing the decision-making and final summary generation for this n8n automation.
Call n8n Workflow Tool: Allows the AI Agent to execute a different n8n workflow (the data processor) as a specialized function. Key configuration involves dynamically passing calculated date ranges.
When Executed by Another Workflow (n8n trigger): The entry point for the data processing sub-workflow, receiving the date inputs from the AI Agent.
Get revenual from google sheet (Google Sheets n8n node): Retrieves all raw data from the specified financial Google Sheet. This is the source of all comparison data.
Pivot current circle, Pivot last circle, Pivot last year cirle (Code n8n node): Essential custom code nodes. They filter the large dataset based on the corresponding period dates, aggregate the 'Số tiền' (Amount) by 'Phân loại' (Category), and return summarized, pivoted data tables. This custom scripting is a highlight of this specialized n8n template.
Merge and Aggregate n8n nodes: Nodes like Sum data current transfer month, Collect all, Change title 1, etc., are used extensively for flow control, combining contextual dates with the pivoted data, and restructuring the final report output before it is returned to the n8n AI Agent.

Related n8n Workflows

Free

Nodes: 12 Nodes
Updated: December 26 2025
View all
Created by
Markhah
Markhah

Featured*