Portfolio Project

Automated Expense Tracker with Telegram and n8n

Log expenses from everyday Telegram messages and receipt photos. The workflow handles parsing, categorization, sheet entry, receipt archiving, and confirmation replies, turning casual chat inputs into organized spending data for better decisions.

n8n Telegram Bot API Gemini 1.5 Flash Google Sheets Google Drive
Telegram
Webhook
Gemini OCR
Rows appended to Google Sheets Receipts archived to Drive when needed

Live Simulation

Simulate text parsing, receipt OCR, Sheets append, Drive upload, and Telegram reply.

Inputs ๐Ÿ“ฅ
0
Parsed โœ…
0
Drive Uploads โ˜
0
Blocked โš 
0

Console Output

Idle
Waiting for workflow simulation...

Telegram Reply Preview

ready

makan siang 35rb di warteg bahari

Kamu ยท text message

Pengeluaran dicatat: Makan ยท Rp 35.000 ยท Warteg Bahari

Expense Bot ยท Markdown reply
Workflow rule Only whitelisted chat IDs are processed. API keys are stored outside the workflow file in production.

Sheet Rows Preview

0 rows
Tanggal Nominal Kategori Deskripsi Sumber Result

How It Works

Key workflow logic adapted from the imported n8n JSON.

1. Extract Telegram Message
const msg = body?.message || body?.edited_message;
const chatId = msg.chat?.id?.toString() || "";
const type = msg.photo ? "photo" : "text";
const text = msg.text || msg.caption || "";
const allowed = ALLOWED.includes(chatId);
2. Ask Gemini for JSON
{
  "tanggal": "YYYY-MM-DD",
  "nominal": 0,
  "kategori": "Makan",
  "deskripsi": "",
  "toko": ""
}
3. Append and Reply
Sheets.append(row);

Telegram.sendMessage({
  chat_id: chatId,
  parse_mode: "Markdown",
  text: confirmationText
});

Key Features

๐Ÿ’ฌ

Telegram-first Input

Users can send casual Indonesian expense notes or upload receipt photos directly from chat.

๐Ÿง 

AI Parsing

Gemini converts messy text and receipt OCR into a consistent JSON expense schema.

๐Ÿ“Š

Sheets Ledger

Every successful parse appends date, amount, category, description, source, owner, and receipt link.

โ˜

Drive Archive

Receipts for bill and health categories can be saved to Drive for reimbursement or audit trails.

Real Workflow Screenshots

Actual Telegram reply, Google Sheets ledger, and n8n canvas from the working automation.

Telegram bot reading a receipt photo and replying with parsed expense details
Telegram input and reply Receipt photo parsed into category, amount, description, merchant, and date.
Google Sheets expense ledger populated by the Telegram bot workflow
Google Sheets ledger Structured rows appended with source, owner, chat ID, and receipt link fields.
n8n workflow canvas showing Telegram, Gemini, Google Drive, Google Sheets, and Telegram reply nodes
n8n workflow canvas Branches for text input, receipt OCR, Drive archive, Sheets append, and Telegram response.

Demo Safety & Setup Notes

This live demo uses mock data and a sanitized n8n template. It does not call Telegram, Gemini, Google Sheets, Google Drive, or n8n.

๐Ÿ”

No live credentials are included

The downloadable n8n workflow is a template. Users bring their own Telegram bot token, Gemini API key, Google credentials, Sheet ID, Drive folder ID, and allowed chat IDs before running it in their own n8n instance.

Setup Checklist

template ready
Area Template behavior User action
Secrets Uses placeholder environment variables. Add your own credentials in n8n
Access Control Reads allowed chat IDs from config. Set ALLOWED_CHAT_IDS
Receipt Upload Uploads only receipt photos for selected categories. Set Drive folder and category rules
Timezone Provides a timezone config value. Use the timezone for your region
Parsing Returns structured JSON for Sheets. Review unclear receipt outputs