Gmail + Telegram to Google Sheets, expenses logged
Expense tracking falls apart in boring ways. You miss a small UPI charge, you forget a cash note you texted yourself, and suddenly your “budget” is just a hopeful spreadsheet you update once a month.
This expense logging automation hits busy founders and household managers hardest, but marketing leads running team cards and ops folks reconciling tools feel it too. The outcome is simple: your transactions get captured, categorized, and logged without the daily copy-paste grind.
You’ll see how this n8n workflow pulls transactions from Gmail and Telegram, uses AI to structure the details, and writes everything into Google Sheets so your budget tracker stays current.
How This Automation Works
The full n8n workflow, from trigger to final output:
n8n Workflow Template: Gmail + Telegram to Google Sheets, expenses logged
flowchart LR
subgraph sg0["Telegram Flow"]
direction LR
n0["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/telegram.svg' width='40' height='40' /></div><br/>Telegram Trigger"]
n1@{ icon: "mdi:brain", form: "rounded", label: "Google Gemini Chat Model", pos: "b", h: 48 }
n2@{ icon: "mdi:robot", form: "rounded", label: "Budget information extractor", pos: "b", h: 48 }
n3@{ icon: "mdi:brain", form: "rounded", label: "Google Gemini Chat Model1", pos: "b", h: 48 }
n4@{ icon: "mdi:robot", form: "rounded", label: "Expense information extractor", pos: "b", h: 48 }
n5@{ icon: "mdi:brain", form: "rounded", label: "Google Gemini Chat Model2", pos: "b", h: 48 }
n6@{ icon: "mdi:robot", form: "rounded", label: "Structured Output Parser", pos: "b", h: 48 }
n7@{ icon: "mdi:robot", form: "rounded", label: "Structured Output Parser1", pos: "b", h: 48 }
n11@{ icon: "mdi:robot", form: "rounded", label: "Information extraction from ..", pos: "b", h: 48 }
n12@{ icon: "mdi:swap-horizontal", form: "rounded", label: "Raw check if the transaction..", pos: "b", h: 48 }
n13@{ icon: "mdi:swap-horizontal", form: "rounded", label: "Check if the transaction is ..", pos: "b", h: 48 }
n14@{ icon: "mdi:database", form: "rounded", label: "Append transaction data to b..", pos: "b", h: 48 }
n15@{ icon: "mdi:database", form: "rounded", label: "Append transaction data to e..", pos: "b", h: 48 }
n16["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/telegram.svg' width='40' height='40' /></div><br/>Send a confirmation reply to.."]
n0 --> n11
n1 -.-> n11
n6 -.-> n4
n3 -.-> n2
n5 -.-> n4
n7 -.-> n2
n2 --> n13
n4 --> n13
n14 --> n16
n15 --> n16
n11 --> n12
n13 --> n14
n13 --> n15
n12 --> n2
n12 --> n4
end
subgraph sg1["Gmail Flow"]
direction LR
n8@{ icon: "mdi:play-circle", form: "rounded", label: "Gmail Trigger", pos: "b", h: 48 }
n9@{ icon: "mdi:brain", form: "rounded", label: "Google Gemini Chat Model3", pos: "b", h: 48 }
n10@{ icon: "mdi:brain", form: "rounded", label: "Google Gemini Chat Model4", pos: "b", h: 48 }
n17["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Extract the email only from .."]
n18@{ icon: "mdi:robot", form: "rounded", label: "Generate the structured data..", pos: "b", h: 48 }
n19@{ icon: "mdi:robot", form: "rounded", label: "Extract the information and ..", pos: "b", h: 48 }
n20@{ icon: "mdi:swap-horizontal", form: "rounded", label: "Check if the transaction is ..", pos: "b", h: 48 }
n21@{ icon: "mdi:database", form: "rounded", label: "Append transaction data to e..", pos: "b", h: 48 }
n22@{ icon: "mdi:database", form: "rounded", label: "Append transaction data to e..", pos: "b", h: 48 }
n8 --> n17
n9 -.-> n18
n10 -.-> n19
n19 --> n20
n20 --> n21
n20 --> n22
n18 --> n19
n17 --> n18
end
%% Styling
classDef trigger fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
classDef ai fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
classDef aiModel fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
classDef decision fill:#fff8e1,stroke:#f9a825,stroke-width:2px
classDef database fill:#fce4ec,stroke:#c2185b,stroke-width:2px
classDef api fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef code fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
classDef disabled stroke-dasharray: 5 5,opacity: 0.5
class n0,n8 trigger
class n2,n4,n6,n7,n11,n18,n19 ai
class n1,n3,n5,n9,n10 aiModel
class n12,n13,n20 decision
class n14,n15,n21,n22 database
class n17 code
classDef customIcon fill:none,stroke:none
class n0,n16,n17 customIcon
The Problem: Expense tracking breaks when it’s manual
If your spending comes from multiple places (bank alerts, UPI apps like Google Pay or Paytm, card swipes, and random “I’ll log it later” notes), manual tracking becomes a weekly cleanup project. You hunt through Gmail, copy amounts into a sheet, guess categories, then try to remember what “₹430 to XYZ” actually was. One missed email turns into two. Then your budget review is based on incomplete data, which is honestly worse than having no tracker at all because it gives false confidence. Even when you do log everything, small formatting errors and duplicated entries creep in.
The friction compounds. Here’s where it usually breaks down.
- You spend about 10 minutes per transaction copying details from Gmail into a sheet, and it adds up fast across a month.
- UPI and bank emails all look different, so your categories end up inconsistent and your reports get messy.
- Telegram “quick notes” are easy to send and easy to forget, which means cash expenses and odd purchases slip through.
- Budget checks happen after the damage is done because nobody is recalculating totals every day.
The Solution: AI-classified expenses from Gmail and Telegram into Sheets
This workflow watches two inputs: new finance-related emails in Gmail and expense/budget messages sent to a Telegram bot. When a message arrives, it runs the content through an AI parser (Gemini models inside n8n, with an OpenAI Chat Model also present in the workflow) that extracts the fields you actually need for tracking: date, amount, category, description, source, and status. Then it decides what you meant (a budget update or an expense) and appends a clean row to the correct Google Sheets tab. For Gmail transactions, it also detects the account/source based on the sender address or UPI patterns, filters out irrelevant emails, and splits credit vs. debit so your tracker stays structured. Finally, you get a confirmation message in Telegram, and your sheet stays ready for monthly and yearly summaries.
The workflow starts when Gmail or Telegram triggers fire. AI turns unstructured text into consistent columns, then Google Sheets becomes your single log. If your totals exceed the budget you set in the Budgets tab, you can raise an alert (the workflow supports alerts, and the provided approach includes a Google Sheets Apps Script for email notifications).
What You Get: Automation vs. Results
| What This Workflow Automates | Results You’ll Get |
|---|---|
|
|
Example: What This Looks Like
Say you have about 2 bank/UPI transaction emails a day and you also drop 1 manual expense note into Telegram. Manually, that’s roughly 10 minutes per item to open the message, read it, format a row, and pick a category, or about 30 minutes a day (around 15 hours a month). With this workflow, you spend maybe 2 minutes sending a Telegram note when needed, and Gmail entries happen on their own while you work. You still review the sheet sometimes, but the daily logging basically disappears.
What You’ll Need
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- Google Sheets to store Expenses and Budgets tabs.
- Gmail for incoming bank and UPI transaction emails.
- Telegram Bot to submit manual expenses or budgets quickly.
- Gemini API key (get it from Google AI Studio or your Google Cloud project).
Skill level: Intermediate. You will connect accounts, paste API keys, and do light setup in Google Sheets (tabs and columns) without writing code in n8n.
Don’t want to set this up yourself? Talk to an automation expert (free 15-minute consultation).
How It Works
Gmail or Telegram kicks it off. A Gmail trigger watches for new messages, while a Telegram trigger listens for messages sent to your bot. Two inputs, one tracker.
Finance-only filtering happens early. A small code-based filter checks sender patterns (HDFC, Indian Bank, Indian Overseas Bank, and common UPI formats) so you don’t log random inbox noise. If it can’t match the sender to a known source, it skips the entry.
AI turns messy text into clean columns. The workflow sends the email body or Telegram message to an AI “structuring” chain, then a structured parser extracts consistent fields like date, amount, account, type (credit/debit), and category. This is the part that makes the sheet usable long-term.
Google Sheets becomes the system of record. Expenses go to the Expenses tab (with separate branches for credit and debit), budgets go to the Budgets tab, and Telegram posts back a confirmation so you know it logged successfully.
You can easily modify the sender detection and categories to match your own banks and budget structure. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Triggers
This workflow starts from Telegram messages and Gmail alerts, so both trigger nodes must be configured first.
- Open Telegram Intake Trigger and connect your Telegram bot to listen for Updates set to
message. - Credential Required: Connect your
telegramApicredentials in Telegram Intake Trigger (this is required even though it is not preconfigured). - Open Gmail Intake Trigger and confirm Poll Times is set to
everyHour. - Credential Required: Connect your Gmail OAuth credentials in Gmail Intake Trigger (not configured in the template).
Step 2: Connect Google Sheets
All finance entries are appended to the Budgets and Expenses sheets in the Finances spreadsheet.
- Open Append Budget Sheet Row and set Document to
[YOUR_ID]and Sheet toBudgets. - Map the column values in Append Budget Sheet Row to expressions like
{{$json.output.Month}},{{$json.output['Budget Amount']}}, and{{$json.output.UpdatedAt}}. - Credential Required: Connect your
googleSheetsOAuth2Apicredentials in Append Budget Sheet Row (not configured in the template). - Open Append Expense Sheet Row and confirm the Document is
[YOUR_ID]and Sheet isExpenses. - Ensure Append Expense Sheet Row maps fields like
{{$json.output.Amount}},{{$json.output.Category}}, and{{$json.output.MessageId}}. - Credential Required: Connect your
googleSheetsOAuth2Apicredentials in Append Expense Sheet Row, Append Credit Expense Row, and Append Debit Expense Row.
Step 3: Set Up the AI Parsing Chain
The workflow uses multiple Gemini chat engines and structured parsers to interpret budgets and expenses from Telegram and Gmail inputs.
- Open Gemini Chat Engine A and add your Gemini credentials for use by Telegram Message Parser.
- Credential Required: Connect your
googlePalmApicredentials in Gemini Chat Engine A (not configured in the template). - Confirm Telegram Message Parser uses Text set to
{{$json.message.text}}and its system message includes the required JSON-only output rules. - Verify Budget Detail Extractor and Expense Detail Extractor use Text set to
{{$json.text}}and Prompt Type set todefine. - Ensure Gemini Chat Engine B and Gemini Chat Engine C are connected as the language models for Budget Detail Extractor and Expense Detail Extractor respectively.
- Credential Required: Gemini Chat Engine B and Gemini Chat Engine C must use
googlePalmApicredentials (already configured). - For the structured parsers, keep Expense Schema Parser and Budget Schema Parser schemas as provided. Credentials for these parsers must be added to their parent nodes (Budget Detail Extractor and Expense Detail Extractor), not the sub-nodes.
- Confirm LLM Email Structuring uses Text set to
{{$json.snippet}}and is connected to Gemini Chat Engine D, which already hasgooglePalmApicredentials configured. - Confirm Parse Email Details uses Text set to
{{$json.text}}and is connected to Gemini Chat Engine E withgooglePalmApicredentials configured.
Step 4: Configure Filtering and Routing Logic
Routing nodes determine whether the input is a budget or expense and where expense entries should be stored.
- In Filter Finance Email Sources, keep the existing JavaScript to whitelist finance email senders and identify the
accountvalue. - Confirm Initial Budget vs Expense Check uses the condition
{{ JSON.parse($json.text.replace(/```json\n?|```/g, '').trim()).type }}equalsbudget. - Ensure Final Budget vs Expense Gate checks
{{$json.output.type}}equalsbudgetbefore writing to the budgets sheet. - Verify Credit vs Debit Branch checks
{{$json.output.type}}equalsCreditto route to Append Credit Expense Row; the false branch routes to Append Debit Expense Row.
Step 5: Configure Output Notifications
After a row is appended, the workflow sends a Telegram confirmation to the originating user.
- Open Send Telegram Confirmation and confirm Chat ID is set to
{{$('Telegram Intake Trigger').item.json.message.from.id}}. - Update the confirmation Text message if needed, keeping the spreadsheet URL updated:
https://docs.google.com/spreadsheets/d/[YOUR_ID]/edit?usp=sharing. - Credential Required: Connect your
telegramApicredentials in Send Telegram Confirmation (already configured).
Step 6: Test and Activate Your Workflow
Run end-to-end tests from both Telegram and Gmail to validate routing and sheet updates.
- Click Execute Workflow and send a Telegram message like “Set budget for groceries 5000” to trigger Telegram Intake Trigger.
- Verify a new row appears in the
Budgetssheet via Append Budget Sheet Row and a Telegram response is sent by Send Telegram Confirmation. - Send a test bank alert email to the Gmail inbox used by Gmail Intake Trigger and confirm Filter Finance Email Sources passes it through.
- Check that the entry is routed through Credit vs Debit Branch and appended by either Append Credit Expense Row or Append Debit Expense Row.
- Once verified, switch the workflow to Active for production use.
Common Gotchas
- Google Sheets credentials can expire or need specific permissions. If things break, check the n8n credential connection status and that the spreadsheet is shared with the connected Google account first.
- If you’re using Wait nodes or external rendering, processing times vary. Bump up the wait duration if downstream nodes fail on empty responses.
- Default prompts in AI nodes are generic. Add your brand voice early or you’ll be editing outputs forever.
Frequently Asked Questions
About an hour if your Google Sheet is already prepared.
No. You’ll mostly connect accounts, add API keys, and map columns in Google Sheets.
Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in Gemini/OpenAI API costs, which are usually small per message but depend on your usage.
Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.
Yes, and you should. The “Filter Finance Email Sources” code step is where you add or change sender patterns (banks, UPI apps), and the AI extraction steps can be updated to include your own categories like Travel, Groceries, Subscriptions, or Client Meals. Many people also tweak the “Budget vs Expense” checks so Telegram messages like “budget food 12000” or “spent 450 coffee” route correctly. Once it’s dialed in, it stays consistent.
Usually it’s an auth issue: the Gmail OAuth token expired, the connected Google account changed, or the trigger lost permission after a security review. Reconnect the Gmail credential in n8n and confirm the workflow is allowed to read the inbox. Also check the filter logic: if the sender doesn’t match your bank/UPI patterns, the workflow may be “working” but intentionally outputting nothing.
For most personal and small-team use, it’s plenty.
Often, yes, because this workflow needs branching logic (budget vs. expense, credit vs. debit) and AI parsing, and those flows can get pricey or awkward on simpler tools. n8n is flexible with “if” gates, merging paths, and structured extraction, so you can keep everything in one automation instead of juggling multiple Zaps. Another big reason is self-hosting, which can make high-volume logging affordable when you have lots of transaction emails. That said, if you only need “Telegram message → add row to sheet,” Zapier or Make might feel faster to set up. If you’re torn, Talk to an automation expert and get a clear recommendation.
Once this is running, your sheet stops being a “someday” admin task and starts reflecting reality. The workflow takes the repetitive logging off your plate so you can make decisions with current numbers.
Need Help Setting This Up?
Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.