Telegram Plaid Bot - Secure Banking Integration for Telegram
A secure Telegram bot that integrates with Plaid's banking API, allowing users to:
- Connect their bank accounts directly through Telegram
- View real-time financial data
- Manage banking information securely
- Execute financial operations via chat interface
Technology Stack:
- Runtime: Node.js 18+ (CommonJS)
- Bot Framework: Telegraf 4.x
- API: Express.js 4.x
- Banking: Plaid API v18
- Database: PostgreSQL with connection pooling
- Security: AES-256-GCM encryption + dotenvx
- Containerization: Docker & Docker Compose
- π Secure Authentication - OAuth2 with encrypted token storage
- π¦ Bank Integration - Direct Plaid API connectivity
- π¬ Chat Interface - Natural Telegram bot interaction
- π Real-time Data - Live account balances and transactions
- π Encrypted Secrets - dotenvx for environment management
- π¦ Container Ready - Docker & docker-compose support
- πͺ΅ Structured Logging - Winston logging throughout
- β‘ Rate Limited - Express rate-limiting middleware
# Clone repository
git clone https://github.com/johnconstant99-dev/telegram-plaid-bot.git
cd telegram-plaid-bot
# Install dependencies
npm install
# Setup environment
cp .env.example .env
# Edit .env with your credentials
# Initialize database
npm run init-db
# Start development server
npm run devSee QUICKSTART.md for detailed setup instructions.
Create .env file with required variables:
# Telegram
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_WEBHOOK_SECRET=your_webhook_secret
# Plaid
PLAID_CLIENT_ID=your_client_id
PLAID_SECRET=your_secret
PLAID_ENV=sandbox
# Database
DATABASE_URL=postgresql://user:pass@localhost:5432/telegram_plaid_bot
# Server
NODE_ENV=development
PORT=3000For production, use encrypted environment management:
npm run env:keygen # Generate keys
dotenvx set VAR "value" -f .env.production # Set encrypted varsSee ENVIRONMENT_SETUP.md for details.
src/
βββ index.js # Application entry point
βββ bot/ # Telegram bot implementation
β βββ index.js # Bot initialization
β βββ commands/ # Command handlers
β βββ middleware/ # Bot middleware
βββ api/ # Express REST API
β βββ server.js # Server configuration
β βββ routes/ # Route definitions
β βββ controllers/ # Request handlers
βββ services/ # Business logic
β βββ plaidService.js # Plaid API wrapper
β βββ userService.js # User management
β βββ encryptionService.js # Token encryption
β βββ stripeService.js # Payment processing
βββ models/ # Database models
β βββ User.js # User model
β βββ PlaidConnection.js # Bank connection model
βββ database/ # Database setup
β βββ connection.js # PostgreSQL pool
β βββ init.sql # Schema definition
β βββ init.js # Init script
βββ config/ # Configuration
β βββ index.js # Config management
βββ utils/ # Utilities
βββ logger.js # Winston logger
βββ errorHandler.js # Error handling
# Development
npm start # Start production server
npm run dev # Start with auto-reload (nodemon)
npm run init-db # Initialize database schema
# Environment Management
npm run env:keygen # Generate encryption keys
npm run env:set # Set encrypted variables
npm run env:list # List all environment variables
npm run env:run # Run commands with decrypted env- Encryption: All sensitive tokens encrypted with AES-256-GCM
- Environment: dotenvx for secure secret management
- Database: Connection pooling with parameterized queries
- API: Rate limiting, CORS, Helmet for security headers
- Keys: Private keys stored securely, never committed
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f app
# Stop services
docker-compose down- QUICKSTART.md - New developer setup guide
- docs/ENVIRONMENT_SETUP.md - Environment & encryption guide
- .github/copilot-instructions.md - Development standards
GitHub Actions workflow automatically:
- β Tests code on push to Main
- π Validates encrypted environment files
- ποΈ Builds application
- π Prepares for deployment
See .github/workflows/deploy.yml for configuration.
- Follow the Copilot Instructions
- Use CommonJS modules (
require/module.exports) - Implement async/await with try-catch
- Add Winston logging, not console.log
- Test locally before pushing
MIT License - see LICENSE file for details
johnconstant99-dev
- GitHub: @johnconstant99-dev
Made with β€οΈ for secure financial data management