Production-oriented Telegram bot for GoldenBite fast-food ordering: catalog browsing (inline query), cart/checkout, and admin product/category management.
- Node.js 18+
- node-telegram-bot-api (long polling)
- MongoDB + Mongoose
- Cloudinary (product images)
- Joi (input validation)
- Copy env template and fill values:
cp .env.example .env- Install dependencies:
npm install- Start MongoDB, then run:
npm start
# or for local development with auto-reload:
npm run devRequired env vars are validated at boot — the process exits if any are missing.
| Variable | Description |
|---|---|
BOT_TOKEN |
Telegram bot token from @BotFather |
ADMIN_ID |
Telegram user id of the admin |
BOT_USERNAME |
Bot username without @ (used in UI mentions) |
DB_URI / dbUri |
MongoDB connection string |
DB_NAME |
Database name |
CLOUD_NAME, API_KEY, API_SECRET_KEY |
Cloudinary credentials |
Enable Inline Mode for the bot in BotFather so category/product search works.
- Registration (name + Telegram contact share)
- Browse products via inline query
- Cart, confirm order, choose cash/card-on-delivery
- Profile view / name edit
- Category CRUD wizard (scoped to admin chat)
- Product CRUD with Cloudinary photos
- Client list with recent orders
- New-order notifications + mark as delivered
- Admin-only callbacks are authorized against
ADMIN_ID - Order totals are recomputed from the database (not trusted from callback payloads)
- Contact registration verifies
contact.user_idmatches the sender - Inline search regex input is escaped
- FSM wizards are scoped by admin/client
chatId(no global shared draft state)
Online PayMe/Click integrations are not included. Checkout uses cash or card to courier. Wire a real payment provider before advertising online payments.
src/
index.js # boot, graceful shutdown
config.js # env validation + FSM constants
bot/ # Telegram listeners + handlers
model/ # Mongoose models
lib/ # DB, Cloudinary, logger
utils/ # auth, async wrapper, validation
other/text.service.js # UI copy
# Set DB_URI=mongodb://mongo:27017 in .env when using compose
docker compose up -d --build- Logs are JSON lines to stdout (
LOG_LEVEL=info|warn|error|debug) SIGINT/SIGTERMstop polling and close MongoDB- Run a single bot instance with polling (use webhooks for multi-instance)
- Transitive
npm auditfindings come fromnode-telegram-bot-api→ deprecatedrequest; monitor upstream or migrate to grammY/Telegraf when ready