Full documentation for deployment, configuration, user flows, admin flows, referral logic, SQLAdmin, multibot mode, and media demos.
- Deployment and configuration
- User manual
- Admin manual
- Cryptocurrency forwarding
- Referral system
- SQLAdmin web admin panel
- Multibot experimental
- Demo gallery
- Todo list
| Environment Variable Name | Description | Recommended Value |
|---|---|---|
WEBHOOK_PATH |
The path to the webhook where Telegram servers send requests for bot updates. Change it if you deploy several bots on one server. | / |
WEBAPP_HOST |
Hostname for the Telegram bot service. | 0.0.0.0 for Docker Compose, localhost for local deployment |
WEBAPP_PORT |
Port for the Telegram bot service. | 5000 |
TOKEN |
Telegram bot token from @BotFather. |
No recommended value |
ADMIN_ID_LIST |
Comma-separated list of Telegram IDs that can access the admin menu. | No recommended value |
SUPPORT_LINK |
Telegram support profile URL used by the Help button. | https://t.me/${YOUR_USERNAME_TG} |
POSTGRES_USER |
PostgreSQL username. | postgres |
POSTGRES_PASSWORD |
PostgreSQL password. | Any strong value |
DB_PORT |
PostgreSQL port. | 5432 |
DB_HOST |
PostgreSQL host. | postgres |
NGROK_TOKEN |
Ngrok token for development tunnel mode. | No recommended value |
PAGE_ENTRIES |
Pagination size. | 8 |
MULTIBOT |
Enables experimental multibot mode. Accepts "true" or "false". |
"false" |
CURRENCY |
Fiat currency used in the bot. | "USD", "EUR", "JPY", "CAD", or "GBP" |
RUNTIME_ENVIRONMENT |
"dev" uses ngrok, "prod" uses reverse proxy flow. |
"prod" or "dev" |
WEBHOOK_SECRET_TOKEN |
Protects Telegram webhook requests from spoofing. | Any strong value |
KRYPTO_EXPRESS_API_KEY |
API key from KryptoExpress. | No recommended value |
KRYPTO_EXPRESS_API_URL |
KryptoExpress API URL. | https://KryptoExpress.pro/api |
KRYPTO_EXPRESS_API_SECRET |
Protects KryptoExpress callbacks from spoofing. | Any strong value |
REDIS_PASSWORD |
Required for throttling. | Any strong value |
REDIS_HOST |
Redis host. | redis for Docker Compose |
CRYPTO_FORWARDING_MODE |
Enables automatic forwarding of deposits to your own addresses. | "true" or "false" |
BTC_FORWARDING_ADDRESS |
Required when forwarding mode is enabled. | Bech32 BTC address |
LTC_FORWARDING_ADDRESS |
Required when forwarding mode is enabled. | Bech32 LTC address |
ETH_FORWARDING_ADDRESS |
Required when forwarding mode is enabled. | Ethereum address |
SOL_FORWARDING_ADDRESS |
Required when forwarding mode is enabled. | Solana address |
BNB_FORWARDING_ADDRESS |
Required when forwarding mode is enabled. | BNB address |
MIN_REFERRER_TOTAL_DEPOSIT |
Deposit threshold to unlock referrals. | "500" |
REFERRAL_BONUS_PERCENT |
Referral bonus percent for invited users. | "5" |
REFERRAL_BONUS_DEPOSIT_LIMIT |
Number of referred-user deposits eligible for bonus. | "3" |
REFERRER_BONUS_PERCENT |
Bonus percent for the inviter. | "3" |
REFERRER_BONUS_DEPOSIT_LIMIT |
Number of deposits per referral that reward the inviter. | "5" |
REFERRAL_BONUS_CAP_PERCENT |
Cap for referred-user bonus. | "7" |
REFERRER_BONUS_CAP_PERCENT |
Cap for inviter bonus. | "7" |
TOTAL_BONUS_CAP_PERCENT |
Global combined bonus cap. | "12" |
SQLADMIN_RAW_PASSWORD |
Password for SQLAdmin login. | Strong random string |
JWT_EXPIRE_MINUTES |
JWT expiration time for SQLAdmin auth. | "30" |
JWT_ALGORITHM |
JWT algorithm. | "HS256" |
JWT_SECRET_KEY |
Secret for JWT generation. | Strong random string |
Run on a VPS:
sudo sh -c "$(curl -fsSL https://raw.githubusercontent.com/ilyarolf/AiogramShopBot/refs/heads/master/scripts/deploy.sh)"The interactive script will prompt you for .env values.
For local development on a computer that is not internet-facing, set RUNTIME_ENVIRONMENT="dev". The bot will use an ngrok tunnel.
Note
You need a valid ngrok account and token. Redis is still required.
For production, you can use your own hostname behind Caddy or services like sslip.io. Caddy can automatically provision TLS and act as a reverse proxy. If you already have a reverse proxy, remove the Caddy service and configure routing yourself.
Note
Local deployment still requires PostgreSQL, Redis, and a reverse proxy or tunnel setup.
git clone https://github.com/ilyarolf/AiogramShopBot.git
pip install -r requirements.txt
python run.pyExample .env:
WEBHOOK_PATH="/"
WEBAPP_HOST="localhost"
WEBAPP_PORT=5000
TOKEN="1234567890:QWER.....TYI"
ADMIN_ID_LIST=123456,654321
SUPPORT_LINK="https://t.me/your_username_123"
POSTGRES_USER="postgres"
POSTGRES_PASSWORD="qwertyu"
DB_PORT="5432"
DB_HOST="localhost"
POSTGRES_DB="aiogram-shop-bot"
NGROK_TOKEN="NGROK_TOKEN_HERE"
PAGE_ENTRIES="8"
MULTIBOT="false"
CURRENCY="USD"
RUNTIME_ENVIRONMENT="PROD"
WEBHOOK_SECRET_TOKEN="1234567890"
KRYPTO_EXPRESS_API_KEY="API_KEY_HERE"
KRYPTO_EXPRESS_API_URL="https://kryptoexpress.pro/api"
KRYPTO_EXPRESS_API_SECRET="1234567890"
REDIS_PASSWORD="1234567890"
REDIS_HOST="localhost"
CRYPTO_FORWARDING_MODE="false"
BTC_FORWARDING_ADDRESS=""
LTC_FORWARDING_ADDRESS=""
ETH_FORWARDING_ADDRESS=""
SOL_FORWARDING_ADDRESS=""
BNB_FORWARDING_ADDRESS=""
MIN_REFERRER_TOTAL_DEPOSIT="500"
REFERRAL_BONUS_PERCENT="5"
REFERRAL_BONUS_DEPOSIT_LIMIT="3"
REFERRER_BONUS_PERCENT="3"
REFERRER_BONUS_DEPOSIT_LIMIT="5"
REFERRAL_BONUS_CAP_PERCENT="7"
REFERRER_BONUS_CAP_PERCENT="7"
TOTAL_BONUS_CAP_PERCENT="12"
SQLADMIN_RAW_PASSWORD="admin"
JWT_EXPIRE_MINUTES="30"
JWT_ALGORITHM="HS256"
JWT_SECRET_KEY="1234567890"User registration happens automatically on the first /start command.
- Open
👤 My profile - Open
➕ Top Up Balance - Select a cryptocurrency
- Copy the payment address
- Send crypto and wait for confirmation
Open All categories, select a category, select a subcategory, choose quantity, and confirm the purchase.
Open My Profile -> Purchase History to see previous purchases and open details for each one.
Add the Telegram ID to ADMIN_ID_LIST, separated by commas, and restart the bot.
Example:
ADMIN_ID_LIST=123456,654321- Open
🔑 Admin Menu - Open
📢 Announcements - Select
📢 Send to Everyone - Type or forward a message
- Confirm or decline the sending
Generated from items where is_new = true.
Generated from items where is_sold = false.
Send a .json file after opening 🔑 Admin Menu -> 📦 Inventory Management -> ➕ Add Items -> JSON.
Note
private_datais what the user receives after purchase.
Example:
[
{
"item_type": "Physical",
"category": "Category#1",
"subcategory": "Subcategory#1",
"price": 50,
"description": "Mocked description",
"private_data": null
},
{
"item_type": "Digital",
"category": "Category#2",
"subcategory": "Subcategory#2",
"price": 100,
"description": "Mocked description",
"private_data": "Mocked private data"
}
]Open 🔑 Admin Menu -> 📦 Inventory Management -> ➕ Add Items -> TXT and send a .txt file.
Example:
PHYSICAL;CATEGORY#1;SUBCATEGORY#1;DESCRIPTION#1;50.0;null
PHYSICAL;CATEGORY#1;SUBCATEGORY#1;DESCRIPTION#1;50.0;null
PHYSICAL;CATEGORY#1;SUBCATEGORY#1;DESCRIPTION#1;50.0;null
PHYSICAL;CATEGORY#1;SUBCATEGORY#1;DESCRIPTION#1;50.0;null
DIGITAL;CATEGORY#1;SUBCATEGORY#1;DESCRIPTION#1;50.0;PRIVATE_DATA#5
DIGITAL;CATEGORY#1;SUBCATEGORY#1;DESCRIPTION#1;50.0;PRIVATE_DATA#6
DIGITAL;CATEGORY#1;SUBCATEGORY#1;DESCRIPTION#1;50.0;PRIVATE_DATA#7
DIGITAL;CATEGORY#1;SUBCATEGORY#1;DESCRIPTION#1;50.0;PRIVATE_DATA#8Note
Deleting a category or subcategory removes all unsold products bound to it fromAll categories.
Find a user by Telegram ID or username and increase their balance.
Find a user by Telegram ID or username and reduce their balance.
Select a purchase from the refund menu and confirm or cancel the refund.
Open 🔑 Admin Menu -> 📊 Analytics & Reports, select an entity, then choose the time range.
Note
All Telegram IDs fromADMIN_ID_LISTreceive admin notifications.
Open 🔑 Admin Menu -> 📷 Media management to change category, subcategory, or button media.
Note
Media can be GIFs, images, or videos.
Select the coupon type, usage limit, value, coupon name, then confirm or cancel.
Select an existing coupon and choose whether to enable or disable it.
Open 🔑 Admin Menu -> 📦 Shipping management -> 🚚 Create new shipping option.
Open 🔑 Admin Menu -> 📦 Shipping management -> 📋 View all shipping options.
Used mainly to view user purchases and update tracking numbers for physical orders.
Used to view and moderate customer reviews.
You can enable cryptocurrency forwarding so deposits received via KryptoExpress are redirected to your own addresses.
To enable it:
- set
CRYPTO_FORWARDING_MODE=true - set the required
{CRYPTO}_FORWARDING_ADDRESSvalues in.env
Note
BTC and LTC forwarding addresses must use Bech32 format.
The referral system is designed to stimulate organic growth while keeping the bonus economy controlled and predictable. Bonuses are credited as internal balance and cannot be withdrawn.
A user becomes eligible to use referrals only after reaching MIN_REFERRER_TOTAL_DEPOSIT.
Each eligible user gets a unique referral link. When a new user joins via that link and later makes a deposit, the referral relationship becomes permanent.
REFERRAL_BONUS_PERCENTREFERRAL_BONUS_DEPOSIT_LIMITREFERRAL_BONUS_CAP_PERCENT
REFERRER_BONUS_PERCENTREFERRER_BONUS_DEPOSIT_LIMITREFERRER_BONUS_CAP_PERCENT
TOTAL_BONUS_CAP_PERCENT limits the combined referral and referrer bonuses generated from a single referred user.
- Access is locked behind a minimum deposit requirement
- Bonuses apply only to a limited number of deposits
- Individual and global caps are enforced
- Self-referrals are forbidden
You can work with database objects using the SQLAdmin admin panel.
- URL:
{YOUR_IP_ADDRESS}.sslip.io/admin - Login:
admin - Password:
${SQLADMIN_RAW_PASSWORD}
- Set
MULTIBOT="true"in Docker Compose - Start the stack with
docker-compose up - This launches one main manager bot
- Child bots are added only through the main bot
- Only Telegram IDs from
ADMIN_ID_LISTcan connect child bots - To add a managed bot, send
/add {token}to the main bot - Connected child bot tokens are stored in Redis under
multibot:tokens - On startup, the app restores child bot webhooks from Redis automatically
- In multibot mode, direct user notifications and announcement delivery try all known bot tokens with a short delay between attempts
User-facing demos are shown in the main README. Additional admin demos in this file:
- Send to Everyone
- Restocking Message
- Current Stock
- Add Items JSON
- Add Items TXT
- Delete Category/Subcategory
- Credit Management
- Refunds
- Statistics
- Admin notifications
- Media management
- Coupons
- Shipping management
- Buys management
- Reviews management
- Make migration from direct raw database queries to SQLAlchemy ORM.
- Add option to encrypt database via SQLCipher when using SQLAlchemy.
- Add option to generate new crypto addresses using new mnemonic phrases so that
1 user = 1 mnemonic phrase. - Items pagination.
- Database backup from Telegram admin actions.
- Sales and users statistics in Telegram admin.
- Deposit statistics in Telegram admin.
- Product sorting by name, quantity, and price.
- Product search and filtering.
- Cryptocurrency forwarding mode.
- Media for categories, subcategories, and buttons.
- Improved shopping cart with
+1and-1marketplace-like controls. - Improved user management with blocking.
- Review functionality.
- Support for physical goods with shipping.
- Multiple localization with i18n.
- Referral system.
- SQLAdmin web interface.
- Interactive deployment script.




















