A powerful Telegram bot that brings crypto payments to your fingertips! Built to seamlessly integrate with CopperX Payout API, this bot helps you manage wallets, send crypto, withdraw funds, and track transactions - all through the familiar Telegram interface.
-
🔐 Authentication & Account Management
- Secure email-based OTP login with Copperx credentials
- View account profile and KYC/KYB status
-
💰 Wallet Management
- Check balances across multiple networks
- Set default wallet for transactions
- Generate wallet addresses for deposits
-
📤 Send Crypto - Multiple ways to send:
- Send to email addresses (no wallet needed!)
- Send to crypto wallets directly
- Send batch payments to multiple recipients
-
💸 Withdrawals - Cash out to your bank account
-
📊 Transaction History - Track all your transactions
-
🔔 Real-time Notifications - Receive deposit notifications via Pusher
- Node.js & TypeScript - Rock-solid foundation
- Telegraf - Elegant Telegram Bot framework
- Redis - For persistent session management
- Axios - API communication
- Pusher - Real-time notifications
src/
├── api/ # API integration with CopperX services
│ ├── auth.ts # Authentication API calls
│ ├── wallet.ts # Wallet management API calls
│ ├── transfers.ts # Fund transfer API calls
│ ├── kyc.ts # KYC verification API calls
│ └── notifications.ts # Notification handlers
├── bot/ # Telegram bot functionality
│ ├── commands/ # Bot command implementations
│ ├── keyboards/ # Telegram inline keyboards
│ └── middleware/ # Bot middleware (auth, etc.)
├── config/ # Application configuration
├── constants/ # App constants and icons
├── services/ # Background services
├── types/ # TypeScript type definitions
├── utils/ # Helper utilities
│ ├── format.ts # Formatting helpers
│ ├── lifecycle.ts # Bot lifecycle management
│ ├── redisSession.ts # Redis session implementation
│ ├── validation.ts # Input validation helpers
│ └── session.ts # Session management utilities
└── index.ts # Main application entry point
-
Clone the repository
git clone https://github.com/yourusername/copperxbot.git cd copperxbot -
Install dependencies
npm install
-
Configure environment variables
cp .env.example .env # Edit .env with your tokens and configuration -
Run in development mode
npm run dev
-
Configure environment variables
cp .env.docker.example .env # Edit .env with your configuration -
Build and run with Docker Compose
docker-compose up -d
-
Check logs
docker-compose logs -f
-
Launch an EC2 instance (t2.micro is sufficient)
-
Install Docker and Docker Compose
sudo yum update -y sudo amazon-linux-extras install docker sudo service docker start sudo usermod -a -G docker ec2-user sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose -
Clone and deploy the bot
git clone https://github.com/yourusername/copperxbot.git cd copperxbot cp .env.docker.example .env # Edit .env with your configuration docker-compose up -d
npm start- Start the bot in production modenpm run dev- Start with nodemon for developmentnpm run build- Build TypeScript filesnpm run clean-start- Kill existing process, rebuild, and startnpm run start-prod- Start in production with process managementnpm run lint- Run ESLint on source codenpm run format- Format code with Prettier
-
Bot Initialization: The entry point is
src/index.tswhich initializes the Telegraf bot, sets up Redis session management, and registers command handlers. -
Commands: Each command (like
/send,/balance) is implemented as a separate module in thebot/commands/directory using Telegraf's Composer pattern. -
API Integration: The
api/directory contains modules for communicating with CopperX API endpoints, handling authentication, wallet management, and transfers. -
Session Management: User sessions are managed using Redis, allowing persistent state across bot restarts. Session utilities are in
utils/session.tsandutils/redisSession.ts. -
Workflow Management: Complex operations like sending funds implement multi-step workflows, maintaining state in the user's session.
The bot uses a secure email OTP-based authentication system:
- User provides email address
- System sends OTP to email
- User confirms OTP in Telegram
- System issues JWT token stored in session
/start- Initialize the bot and see the main menu/login- Authenticate with your CopperX account/logout- Sign out from your account/balance- Check your wallet balances/send- Send crypto to emails or wallet addresses/withdraw- Withdraw funds to your bank account/history- View your transaction history/profile- View your account details and KYC/KYB status/help- Show available commands
Configure the bot by setting the following environment variables:
| Variable | Description | Default |
|---|---|---|
BOT_TOKEN |
Your Telegram Bot Token | (Required) |
API_BASE_URL |
CopperX API endpoint | https://income-api.copperx.io/api |
PUSHER_APP_ID |
Pusher app ID for notifications | (Optional) |
PUSHER_KEY |
Pusher key | (Optional) |
PUSHER_SECRET |
Pusher secret | (Optional) |
PUSHER_CLUSTER |
Pusher cluster region | eu |
SESSION_SECRET |
Secret for session encryption | default_secret_key |
SESSION_EXPIRY |
Session timeout in seconds | 86400 |
REDIS_URL |
Redis connection URL | redis://redis:6379 |
To prevent the "409: Conflict: terminated by other getUpdates request" error, ensure that only one instance of the bot is running at a time. The bot includes lifecycle management utilities that create a PID file to track running instances.
If you encounter this error, you have several options:
-
Use the clean start script that will automatically terminate any running instances:
npm run clean-start
-
Manually kill any existing bot processes:
pkill -f 'node.*copperXBot' -
Restart your system or development environment if the issue persists.
-
Check if bot is running:
./scripts/check-bot.sh
-
View real-time logs:
./scripts/view-logs.sh
-
Restart the bot:
./scripts/restart-bot.sh
- All API communications use HTTPS
- User tokens stored in encrypted Redis sessions
- OTP-based authentication for enhanced security
- Configurable session timeouts
- Bot process monitoring to prevent unauthorized deployments
For questions or support, please contact the Copperx team in Telegram at https://t.me/copperxcommunity/2991.
This project is licensed under the ISC License.
Built with ❤️ by @codecShivam