Skip to main content

Automated expense tracking from emails & Telegram with Gemini AI & Google Sheets

Workflow preview

Workflow preview
100%
Automated expense tracking from emails & Telegram with Gemini AI & Google Sheets preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This workflow contains community nodes that are only compatible with the self hosted version of n8n. This n8n template automatically parses bank transaction emails (HDFC, Indian Bank, Indian Overse...

Best for

  • AI Summarization automation workflows
  • Multimodal AI automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.telegramtrigger, @n8n/n8n-nodes-langchain.lmchatgooglegemini, @n8n/n8n-nodes-langchain.chainllm, @n8n/n8n-nodes-langchain.outputparserstructured, n8n-nodes-base.gmailtrigger, n8n-nodes-base.stickynote, n8n-nodes-base.if, n8n-nodes-base.googlesheets

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Alex.

Original n8n.io source

1.1 Workflow description

Title
Automated expense tracking from emails & Telegram with Gemini AI & Google Sheets
Workflow name
Automated expense tracking from emails & Telegram with Gemini AI & Google Sheets

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

This n8n template automatically parses bank transaction emails (HDFC, Indian Bank, Indian Overseas Bank, UPI apps like Google pay, Paytm, etc.) - The from email(bank name/UPI apps) is changable, classifies them using Gemini AI, and logs them into a structured Google Sheets budget tracker. It helps you consolidate expenses, compare against monthly budgets, and get real-time alerts when limits are exceeded.

πŸ“ Problem Statement

Tracking expenses manually from different bank emails and UPI apps is frustrating, time-consuming, and error-prone. Small transactions often slip through, making budget control difficult.

This workflow solves that by:

Automatically extracting financial data from Gmail.

Categorizing expenses using AI parsing.

Saving all data into Google Sheets in a structured way.

Comparing with monthly budgets and raising alerts.

Target Audience:

Individuals who want personal budget automation.

Families managing shared household spending.

Small teams looking for a lightweight financial log.

βš™οΈ Setup

Prerequisites

An n8n instance (self-hosted or cloud).

A Google account with Gmail + Google Sheets enabled.

Pre-created Google Sheets file with 2 tabs:

Expenses

Budgets

A configured Gemini API connection in n8n.

πŸ“Š Google Sheets Template

Expenses Tab (columns in order):

Timestamp | Date | Account | From | To | Type | Category | Description | Amount | Currency | Source | MessageId | Status

Budget Tab (columns in order):

Month | Category | Budget Amount | Notes | UpdatedAt

Yearly Summary Tab (auto-calculated):

Year | Month | Category | Total Expense | Budget | Variance | Alert

Variance = Budget - Total Expense

Alert = ⚠️ Over Budget when spending > budget

πŸš€ How It Works

Gmail:

Gmail Trigger captures new bank/UPI emails.

Gemini AI Parser extracts structured details (date, amount, category, etc.).

Filter Node ensures only valid financial transactions are logged.

Information extractor will extract the information like Date, account, transaction type(Credit/Debit), description, currency, status, messageId, from email, to email, category -> checks if the transaction is 'Credit' or 'Debit' then appends the details to the respective google sheet

Budget Validator checks against monthly allocations.

If the expense is above the budget is raises an alert and will send a email to the connected account.

For sending email I wrote a Google Sheet App script:

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var monthly = ss.getSheetByName("MonthlySummary");
  var yearly = ss.getSheetByName("YearlySummary");

  // Get values from Monthly Summary
  var totalExpense = monthly.getRange("D2").getValue();
  var budget = monthly.getRange("E2").getValue();

  // Get current date info
  var now = new Date();
  var month = Utilities.formatDate(now, "GMT+5:30", "MM");
  var year = Utilities.formatDate(now, "GMT+5:30", "yyyy");

  var status = (totalExpense > budget) ? "Alert" : "";

  // Append to Yearly Summary
  yearly.appendRow([year, month, totalExpense, status]);

  // If budget exceeded, send alert email
  if (status === "Alert") {
    var emailAddress = "YOUR EMAIL";
    var subject = "⚠️ Budget Exceeded - " + month + "/" + year;
    var body = "Your total expenses this month (" + totalExpense +
      ") have exceeded your budget of " + budget + ".\n\n" +
      "Please review your spending.";
    MailApp.sendEmail(emailAddress, subject, body);
  }

  // πŸ”„ Reset Monthly Summary
  var lastRow = monthly.getLastRow();
  if (lastRow > 3) { // assuming headers in first 2-3 rows
    monthly.getRange("A4:C" + lastRow).clearContent();
  }

  // Reset total in D2
  monthly.getRange("D2").setValue(0);
}

Monthly summary auto-calculates the expense and updates the expense for every month and budgets(sum all budgets if there are more than 1 budgets).

Yearly Summary auto-updates and raises over-budget alerts.

Telegram:

Takes input from a telegram bot which is connected to the n8n workflow telegram trigger.

Gemini AI Parser extracts structured details (date, amount, category, etc.).

Then it checks, whether the manually specified details is 'budget' or 'expense', then splits the data -> parse the data -> then again check whether it is 'Budget' or 'Expense' then appends the structured data to the respective google sheet.

Monthly summary auto-calculates the expense and updates the expense for every month and budgets(sum all budgets if there are more than 1 budgets).

Yearly Summary auto-updates and raises over-budget alerts.

πŸ”§ Customization

Add support for more banks/UPI apps by extending the parser schema.

const senderEmail = $input.first().json.From || "";

// Account detection
let account = ""; // you can modify the bank names and UPI names here

if (/alerts@hdfcbank\.net/i.test(senderEmail)) account = "HDFC Bank"; // you can modify the bank names and UPI names here

else if (/ealerts@iobnet\.co\.in/i.test(senderEmail)) account = "Indian Overseas Bank";
else if (/alerts@indianbank\.in/i.test(senderEmail)) account = "Indian Bank";
else if (/@upi|@okhdfcbank|@okaxis|@okicici/i.test(emailBody)) {
    if (/gpay|google pay/i.test(emailBody)) account = "Google Pay";
    else if (/phonepe/i.test(emailBody)) account = "PhonePe";
    else if (/paytm/i.test(emailBody)) account = "Paytm";
    else account = "UPI";
} else {
    account = "Other";
}

// If account is "Other", skip output
if (account === "Other") {
    return [];
}

// Output
return [{
    account,
    from: senderEmail, // exact Gmail "From" metadata
    snippet: emailBody,
    messageId: $input.first().json.id || ""
}];

Create custom categories (e.g., Travel, Groceries, Subscriptions).

Send real-time alerts via Telegram/Slack/Email using n8n nodes.

Share the Google Sheet with family or team for collaborative use.

πŸ“Œ Usage

The workflow runs automatically on every new Gmail transaction email and financial input on the telegram bot.

At the end of each month, totals are calculated in the Yearly Summary tab.

Users only need to maintain the Budget tab with updated monthly allocations.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Telegram Trigger

Type / Role
n8n-nodes-base.telegramTrigger - telegramTrigger
Config choices
Version 1.2

Block 2 - Google Gemini Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 3 - Budget information extractor

Type / Role
@n8n/n8n-nodes-langchain.chainLlm - chainLlm
Config choices
Version 1.7

Block 4 - Google Gemini Chat Model1

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 5 - Expense information extractor

Type / Role
@n8n/n8n-nodes-langchain.chainLlm - chainLlm
Config choices
Version 1.7

Block 6 - Google Gemini Chat Model2

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 7 - Structured Output Parser

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 8 - Structured Output Parser1

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 9 - Gmail Trigger

Type / Role
n8n-nodes-base.gmailTrigger - gmailTrigger
Config choices
Version 1.3

Block 10 - Google Gemini Chat Model3

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 11 - Google Gemini Chat Model4

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 12 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Information extraction from telegram input

Type / Role
@n8n/n8n-nodes-langchain.chainLlm - chainLlm
Config choices
Version 1.7

Block 14 - Raw check if the transaction is 'Budget' or 'Expense'

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 15 - Check if the transaction is 'Budget' or 'Expense'

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 16 - Append transaction data to budget sheet

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 17 - Append transaction data to expense sheet

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 18 - Send a confirmation reply to the user

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 19 - Extract the email only from specified bank/UPI apps or the transactions made from them

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 20 - Generate the structured data from the raw emails

Type / Role
@n8n/n8n-nodes-langchain.chainLlm - chainLlm
Config choices
Version 1.7

Block 21 - Extract the information and parse it

Type / Role
@n8n/n8n-nodes-langchain.informationExtractor - informationExtractor
Config choices
Version 1.2

Block 22 - Check if the transaction is 'Credit' or 'Debit'

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 23 - Append transaction data to expense sheet1

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 24 - Append transaction data to expense sheet2

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Showing the first 24 of 28 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Automated expense tracking from emails & Telegram with Gemini AI & Google Sheets
Complexity advanced
Nodes 28
Categories AI Summarization, Multimodal AI
Author Alex
Published 20 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/7644/7644.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Automated expense tracking from emails & Telegram with Gemini AI & Google Sheets do?

This workflow contains community nodes that are only compatible with the self hosted version of n8n. This n8n template automatically parses bank transaction emails (HDFC, Indian Bank, Indian Overse...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your AI Summarization, Multimodal AI use case.