A Telegram bot that helps you track expenses by automatically parsing expense messages using Google's Gemini AI. The bot extracts expense details from natural language messages and formats them into a structured format.
- 🤖 Telegram bot integration
- 💰 Automatic expense parsing from natural language
- 🧠 Powered by Google's Gemini AI
- 🌐 FastAPI backend
- 🚀 Deployable on Vercel
- Implement persistent storage for expenses (e.g., database integration, google sheet, airtable)
- Add expense history and reporting features
- Support expense categorization
- Add data export functionality
- Send a message to the bot with your expense (e.g., "coffee $5" or "lunch 150000 IDR")
- The bot uses Gemini AI to parse the message and extract:
- Item name
- Amount
- Currency
- The bot responds with the parsed expense details in a structured format
- Python 3.7+
- Telegram Bot Token (from @BotFather)
- Google Gemini API Key
Create a .env
file with the following variables:
TELEGRAM_TOKEN=your_telegram_bot_token
GEMINI_API_KEY=your_gemini_api_key
- Clone the repository:
git clone https://github.com/yusufmalikul/telegram-expense-bot
cd telegram-expense-bot
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Start the FastAPI server:
uvicorn main:app --reload
- Set up a webhook for your Telegram bot (you can use ngrok for local development):
curl -X POST "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook?url=https://your-vercel-webhook-domain.com/"
The project is configured for deployment on Vercel. The vercel.json
file contains the necessary configuration.
- Start a chat with your bot on Telegram
- Send
/start
to verify the bot is working - Send expense messages in natural language, for example:
- "coffee $5"
- "lunch 150000 IDR"
- "groceries 75 USD"
- python-telegram-bot==20.3
- fastapi
- uvicorn
- requests
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.