Skip to content

johnconstant99-dev/telegram-plaid-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

74 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

README

Telegram Plaid Bot - Secure Banking Integration for Telegram

JavaScript PLpgSQL Node.js License

πŸ€– Overview

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

✨ Features

  • πŸ” 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

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • PostgreSQL
  • Docker (optional)
  • Telegram Bot Token (Get one)
  • Plaid API Key (Sign up)

Installation

# 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 dev

See QUICKSTART.md for detailed setup instructions.

πŸ“‹ Environment Configuration

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=3000

For production, use encrypted environment management:

npm run env:keygen                    # Generate keys
dotenvx set VAR "value" -f .env.production  # Set encrypted vars

See ENVIRONMENT_SETUP.md for details.

πŸ—οΈ Project Structure

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

πŸ“š Available Commands

# 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

πŸ” Security

  • 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

🐳 Docker Deployment

# Start all services
docker-compose up -d

# View logs
docker-compose logs -f app

# Stop services
docker-compose down

πŸ“– Documentation

πŸ”„ CI/CD

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.

🀝 Contributing

  1. Follow the Copilot Instructions
  2. Use CommonJS modules (require/module.exports)
  3. Implement async/await with try-catch
  4. Add Winston logging, not console.log
  5. Test locally before pushing

πŸ“ License

MIT License - see LICENSE file for details

πŸ†˜ Support

πŸ‘€ Author

johnconstant99-dev


Made with ❀️ for secure financial data management

About

telegram ai bot

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors