A full-featured e-commerce Telegram bot built with Node.js. Browse categories and products, manage your cart, checkout with discount codes, leave reviews, and get support—all inside Telegram.
- Catalog — Browse categories and product details
- Shopping cart — Add/remove items, view cart
- Checkout — Discount codes, shipping options, payment flow
- User profile — Account and order history
- Reviews — Rate products, write comments, paginated review list
- Support — Live support chat with clear/close actions
- PGP key — Display shop PGP key for secure contact
- Menu — Inline keyboards and reply keyboard for quick navigation
- Node.js — Runtime
- node-telegram-bot-api — Telegram Bot API (long polling)
- MongoDB — Database (via Mongoose)
- Winston — Logging
- dotenv — Environment configuration
- Node.js (v14+)
- MongoDB running locally or a remote connection string
- A Telegram Bot Token from @BotFather
-
Clone the repo
git clone https://github.com/echandsome/shop-telegram-bot.git cd shop-telegram-bot -
Install dependencies
npm install
-
Configure environment
Create a
.envfile in the project root:TELEGRAM_BOT_TOKEN=your_bot_token_here
Optional: override the database URL in
config/config.js(default:mongodb://localhost:27017/telegramBot). -
Start MongoDB (if local)
Ensure MongoDB is running on
localhost:27017or update the connection string inconfig/config.js. -
Run the bot
npm start
The bot uses
nodemonfor development (auto-restart on file changes). For production, run withnode index.jsor use a process manager like PM2.
├── bot/
│ ├── commands/ # Command handlers (start, cart, checkout, etc.)
│ ├── handlers.js # Route commands and callback queries
│ └── keyboards.js # Inline and reply keyboards
├── config/
│ └── config.js # App config (env, DB URL, logs)
├── data/ # Mongoose models and DB connection
├── services/ # Business logic (user, cart, order, review, etc.)
├── utils/ # Logging and helpers
├── index.js # Entry point
└── package.json
| Command | Description |
|---|---|
/start |
Welcome and main menu |
/products |
Browse categories/products |
/cart |
View or manage cart |
/profile |
User profile |
/reviews |
Product reviews |
/support |
Support chat |
/pgpkey |
Shop PGP key |
ISC