A Telegram bot that helps you track expenses and automatically saves them to Notion. This bot uses the Gemini AI to intelligently extract expense information from natural language messages and photos with receipts.
- 📷 Upload and process receipts with captions
- 🤖 AI-powered expense extraction from natural language messages
- 📊 Automatic categorization of expenses and save to Notion
- Bun installed on your system
- A Telegram Bot Token (from BotFather)
- A Notion account with the Ultimate Budget & Expense Tracker template
- A Google Gemini API key
git clone https://github.com/yourusername/expense-tracker-bot.git
cd expense-tracker-bot
bun install
- Visit Ultimate Budget and Expense Tracker
- Click "Get template"
- The template will be added to your Notion workspace
- Go to Notion Integrations
- Click "Create new integration"
- Name your integration (e.g., "Expense Tracker Bot")
- Select the capabilities required (at minimum: Read content, Update content, Insert content)
- Click "Submit" to create your integration
- Copy the "Internal Integration Token" - this is your
NOTION_API_KEY
- Open your Notion Budget & Expense Tracker template
- For each database (Expenses, Month, Year, Subcategories, Accounts, Recurring Payments), do the following:
- Click on the three dots (•••) in the top right of the database
- Select "Add connections"
- Search for your integration name and select it
- Click "Confirm"
For each database in your Notion workspace, you need to get its ID:
- Open the database in your browser
- Look at the URL, which will be in this format:
https://www.notion.so/workspace/[database-id]?v=[view-id]
- Copy the
[database-id]
part (it's a 32-character string) - Add these IDs to your
.env
file for each database:- Main expenses database
- Month database
- Year database
- Subcategories database
- Accounts database
- Recurring payments database
- Open Telegram and search for @BotFather
- Send the command
/newbot
and follow the instructions - Once your bot is created, BotFather will give you a token
- Copy this token as your
TELEGRAM_BOT_TOKEN
- Go to Google AI Studio
- Create a new API key
- Copy this key as your
GEMINI_API_KEY
- Copy the example environment file:
cp .env.example .env
- Edit
.env
and fill in your API keys and database IDs
bun dev
bun run build
bun start
/start
- Welcome message and introduction/help
- Detailed usage instructions/categories
- List all available expense categories/accounts
- List all available payment accounts
Send a message in one of these formats:
- Simple expense: "Lunch 75k via BCA"
- With category: "Bought coffee 25k category Food using GoPay"
- With date: "Electricity bill 250k on April 3 via Mandiri"
- Multiple expenses: "Breakfast 30k via BCA. Gas 100k via Cash."
- With receipt: Send a photo with a caption describing the expense
Include "new:" or "baru:" in your message:
Bought books 150k category new: Education via BCA
/expense-tracker-bot/
├── src/
│ ├── config/ # Environment and constants
│ ├── controllers/ # Request handlers
│ ├── repositories/ # Database operations
│ ├── services/ # External services (Notion, Telegram, AI)
│ ├── types/ # TypeScript type definitions
│ ├── utils/ # Helper functions
│ └── index.ts # Main entry point
├── .env # Environment variables (private)
└── package.json # Project dependencies
- Income tracking