Skip to content

aliahmadnawawi/bot-tg

Repository files navigation

Telegram Store Bot

Professional Telegram shop bot for selling digital products with balance top-ups, admin panel, and dual payment gateways (Pakasir + Tripay).

This repo is designed for the Sebelas Storebot deployment and can be configured to run on a custom subdomain (e.g., bot-tg.sebelasindonesia.app).

Badges

License Stars Forks Issues Last Commit Last Monday Build

Features

  • Telegram bot storefront with catalog, cart, and order flow
  • Balance top-up system for quick checkout
  • Pakasir payment gateway integration
  • Tripay payment gateway integration (optional, still supported)
  • Admin panel for products, categories, orders, users, and config
  • Payment gateway and payment method configuration in the web panel
  • Automatic payment polling + status updates
  • File-based digital delivery (codes, files, links)
  • SQLite persistence

Tech Stack

  • Node.js + Express
  • SQLite
  • Telegram Bot API
  • Pakasir SDK
  • Tripay REST API

Quick Start

  1. Install dependencies:

    npm install
  2. Create environment file:

    cp env.example .env
  3. Configure .env:

    # Telegram
    TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
    TELEGRAM_WEBHOOK_URL=https://bot-tg.sebelasindonesia.app/webhook
    BASE_URL=https://bot-tg.sebelasindonesia.app
    
    # Database
    DATABASE_PATH=./data/shop.db
    
    # Auth
    JWT_SECRET=your_jwt_secret_here
    
    # Pakasir
    PAKASIR_SLUG=your_pakasir_project_slug
    PAKASIR_API_KEY=your_pakasir_api_key_here
    
    # Tripay (optional)
    TRIPAY_ENVIRONMENT=sandbox
    TRIPAY_API_KEY=your_tripay_api_key_here
    TRIPAY_PRIVATE_KEY=your_tripay_private_key_here
    TRIPAY_MERCHANT_CODE=your_merchant_code_here
    
    # Server
    PORT=3000
    NODE_ENV=production
  4. Start the app:

    npm run dev
  5. Open admin panel:

    • http://localhost:3000/admin

Payment Gateways

Pakasir (Primary)

  • Configure via Admin Panel:
    • Tab: Payment Gateway
    • Section: Pakasir Configuration
    • Enter PAKASIR_SLUG and PAKASIR_API_KEY

Tripay (Optional)

  • Tripay is still supported.
  • Configure via Admin Panel:
    • Tab: Payment Gateway
    • Section: Tripay Payment Configuration

Select Gateway + Methods

  • Admin Panel → Payment GatewayPayment Method Configuration
  • Choose:
    • Default gateway: Pakasir or Tripay
    • Default method
    • Available methods (enable/disable)

Bot Commands

  • /start - Start the bot
  • /shop - Browse products
  • /cart - View cart
  • /orders - Order history
  • /balance - Check balance
  • /deposit - Add balance
  • /help - Help info

Deployment (VPS + Subdomain)

1) Reverse Proxy (Nginx)

Example (replace your domain):

server {
    listen 80;
    server_name bot-tg.sebelasindonesia.app;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

2) SSL

Use Certbot:

sudo certbot --nginx -d bot-tg.sebelasindonesia.app

3) Webhook

Set Telegram webhook:

curl -X POST "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://bot-tg.sebelasindonesia.app/webhook"}'

Admin Panel

  • Default: http://localhost:3000/admin
  • Authentication headers are defined in .env:
    • ADMIN_USERNAME
    • ADMIN_PASSWORD

Scripts

  • npm run dev - Start in dev mode
  • npm start - Start in production
  • npm run init - Setup workflow
  • npm run reset-db - Reset database
  • npm run test:payment-config - Test payment config API

Project Structure

src/
  api/                Admin REST API
  bot/                Telegram bot handlers
  config/             Gateway configs
  database/           SQLite layer + migrations
  routes/             Payment routes
  services/           Payment services
  utils/              Helpers
public/               Admin panel UI

Troubleshooting

  • Ensure .env exists and is loaded
  • Restart the server after editing gateway settings
  • Confirm your subdomain DNS points to the VPS
  • Verify webhook is set to the correct URL

Security

See SECURITY.md for reporting vulnerabilities.

Contributing

See CONTRIBUTING.md.

Code of Conduct

See CODE_OF_CONDUCT.md.

Contributors

Thanks to everyone who contributed:

  • @aliahmadnawawi

License

MIT License. See LICENSE.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published