A bilingual (Arabic/English) Telegram bot for personal finance management, powered entirely by Convex serverless architecture with integrated AI and chart generation.
π€ Live Bot: @FinanceTracker_coderaai_bot
π Project Status: Epic 7 Complete β
- Pure Convex + Telegram Architecture
β‘ Architecture: 100% Serverless - Zero infrastructure, pure Convex + Telegram!
- Natural Language Processing: Add expenses and income using conversational language
- Multi-Account Management: Track multiple bank accounts, cash, and credit cards
- Smart Categorization: AI-powered transaction categorization using RORK
- Chart Generation: Beautiful expense charts (pie, bar, line) with QuickChart API
- Bilingual Support: Full Arabic and English language support
- Real-time Balance Updates: Instant balance calculations and updates
- Serverless Architecture: Fully serverless with Convex - no servers to manage!
β¨ Pure Convex + Telegram Architecture - Zero servers, 100% serverless!
finance-tracker-telegram-bot/
βββ convex/ - Complete serverless backend
β βββ telegram.ts - Webhook handler (HTTP Action)
β βββ messageProcessor.ts - Main message routing & AI integration
β βββ expenseActions.ts - Expense/income processing
β βββ balanceActions.ts - Balance checking & history
β βββ chartGenerator.ts - Chart generation (QuickChart)
β βββ telegramAPI.ts - Telegram Bot API client
β βββ rorkIntegration.ts - RORK AI processing
β βββ userProfiles.ts - User management
β βββ accounts.ts - Account management
β βββ transactions.ts - Transaction operations
β βββ schema.ts - Database schema
βββ docs/ - Documentation
βββ package.json - Convex-only dependencies
βββββββββββββββ
β Telegram β
β Users β
ββββββββ¬βββββββ
β Webhook
βΌ
βββββββββββββββββββββββββββββββ
β Convex HTTP Action β
β - Fast webhook handling β
β - <200ms acknowledgment β
β - Request validation β
ββββββββββββ¬βββββββββββββββββββ
β Direct Processing
βΌ
βββββββββββββββββββββββββββββββ
β Convex Actions β
β - Message Processing β
β - AI Intent Detection β
β - Business Logic β
β - Chart Generation β
ββββββββββββ¬βββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β External APIs β
β - RORK AI (Free) β
β - Telegram Bot API β
β - QuickChart (Free) β
βββββββββββββββββββββββββββββββ
- Node.js: 18.x LTS or higher
- npm: 9.x or higher
- Telegram Bot Token: Get from @BotFather
- Convex Account: Sign up at convex.dev
-
Clone the repository
git clone <repository-url> cd finance-tracker-telegram-bot
-
Install dependencies
npm install
-
Initialize Convex
npx convex dev # Follow the prompts to create a new project # This will generate your CONVEX_URL automatically
-
Configure environment variables
In the Convex dashboard, add these environment variables:
TELEGRAM_BOT_TOKEN- Your bot token from @BotFather
-
Deploy to production
npm run deploy
-
Set up Telegram webhook
curl -X POST "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook" \ -H "Content-Type: application/json" \ -d '{"url":"<YOUR_CONVEX_HTTP_ACTION_URL>/telegram/webhook"}'
# Start development server
npm run dev
# Deploy to production
npm run deploy
# Format code
npm run formattelegram.ts- Webhook handler (HTTP Action)messageProcessor.ts- Main message routing and AI integrationexpenseActions.ts- Expense and income processingbalanceActions.ts- Balance checking and transaction historychartGenerator.ts- Chart generation with QuickChart APItelegramAPI.ts- Telegram Bot API integrationrorkIntegration.ts- AI processing with RORKuserProfiles.ts- User management and preferencesschema.ts- Database schema definition_generated/- Convex generated files
| Variable | Description | Required |
|---|---|---|
TELEGRAM_BOT_TOKEN |
Your Telegram bot token from @BotFather | Yes |
CONVEX_URL |
Convex deployment URL (auto-generated by npx convex dev) |
Yes |
LOG_LEVEL |
Logging level (info/debug/error) | No |
PORT |
Bot server port (default: 3000) | No |
Rork Toolkit API configuration is in config.api.json:
- Base URL:
https://toolkit.rork.com - Endpoints:
/text/llm/for natural language processing - Rate limits: 60 requests/minute recommended
- Retry policies: 3 retries with exponential backoff
- Timeout: 5000ms
Note: Rork API credentials will be configured in Story 3.1 when AI integration is implemented.
# Run all tests
npm test
# Run bot tests only
npm test --workspace=bot
# Run Convex tests only
npm test --workspace=convex
# Run with coverage
npm test -- --coverage- Convex Functions: 80%+ coverage
- Bot Handlers: 60%+ coverage
- Utilities: 90%+ coverage
- Project Status - Current progress and metrics
- Epic 1 Retrospective - Lessons learned
# Deploy to Railway
npm run deploy:bot# Deploy to Convex Cloud
cd convex
npx convex deploy- Runtime: Node.js 18.x LTS
- Language: TypeScript 5.3+
- Bot Framework: node-telegram-bot-api
- Backend: Convex (serverless)
- AI/NLP: Rork Toolkit
- Testing: Jest (bot), Vitest (Convex)
- Code Quality: ESLint, Prettier
[Add your license here]
[Add contribution guidelines here]
For issues and questions:
- Create an issue on GitHub
- Contact: [your-email@example.com]
Built with β€οΈ using Convex and Telegram