A Telegram bot extension for the WordPress Sales Report Excel project. This bot allows generating WooCommerce sales reports directly from Telegram, making it more accessible and user-friendly.
- Generates WooCommerce sales reports via the WordPress Sales Report Excel project.
- Supports private users, restricted groups, and open groups with configurable access.
- Automatically converts Persian/Arabic numbers to English.
- Sends unauthorized access notifications to the bot owner.
- Handles unknown commands gracefully in private chats.
- Works with Docker or directly on the host machine.
- Python 3.13+
- Docker (optional, recommended for container deployment)
- Python packages:
python-telegram-bot==20.4
python-dotenv
- A working WordPress Sales Report Excel setup.
- Telegram Bot Token.
- Clone the repository:
git clone https://github.com/BaseMax/telegram-wordpress-sales-bot.git
cd telegram-wordpress-sales-bot- Install Python dependencies:
pip install -r requirements.txt- Create a
.envfile based on this template:
# Prefix for your project
PROJECT_PREFIX=wpsite
# Command to generate the sales report
TELEGRAM_SALES_REPORT_COMMAND=docker exec wordpress php /var/www/html/files/run.php
# Telegram bot token
TELEGRAM_BOT_TOKEN=<your_bot_token>
# Directory where reports are stored
REPORTS_DIR=/var/www/html/files
# URL prefix to access reports
REPORTS_URL_PREFIX=https://wpsite.com/files
# Users allowed in private chats and restricted groups
ALLOWED_USERS=123456789,987654321
# Groups where everyone is allowed to use the bot
ALLOWED_EVERYONE_IN_CHATS=-1001234567890
# Groups where only specific ALLOWED_USERS are allowed
ALLOWED_CHATS=-1001234567890TELEGRAM_SALES_REPORT_COMMANDcan point to a different Docker container or a script on the host.ALLOWED_USERScontrols private chat and restricted group access.ALLOWED_EVERYONE_IN_CHATSallows all members of specified groups to use the bot.ALLOWED_CHATSrestricts group access to specific users only.
TELEGRAM_BOT_TOKEN: Your bot token from BotFather.REPORTS_DIR: Directory where reports are saved.REPORTS_URL_PREFIX: URL prefix to access generated reports.TELEGRAM_SALES_REPORT_COMMAND: Command to execute the report generation script.ALLOWED_USERS: Comma-separated list of allowed Telegram user IDs.ALLOWED_EVERYONE_IN_CHATS: Comma-separated list of group IDs where everyone can use the bot.ALLOWED_CHATS: Comma-separated list of restricted groups where only specific users can use the bot.
- Start the bot:
python bot.py- Use the
/reportcommand in Telegram:
/report 30
- Generates a report for the last 30 days.
- Responds with a direct URL to download the report.
Example Response:
✅ Report generated:
https://wpsite.com/files/orders-30days-2025-12-04-1c3f5e92-0a4f-4d8b-9f0b-1e2d3f4a5b6c.xlsx
- Unauthorized attempts are notified to the bot owner with user ID and chat info.
- Build and run the container:
docker-compose up -d- The bot will automatically start and poll for messages.
Notes:
- The container mounts the project directory and Docker socket, allowing
TELEGRAM_SALES_REPORT_COMMANDto access other containers. - Make sure the report generation command works either from the host or inside another container.
- Fork the repository.
- Create a branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -am 'Add new feature' - Push to your branch:
git push origin feature/my-feature - Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
Seyyed Ali Mohammadiyeh (Max Base)
- GitHub: BaseMax