Proxmox Telegram Bot

This bot allows you to monitor and control your Proxmox VE infrastructure directly from Telegram. You can list, start, stop, and restart VMs/LXC containers and receive webhook events + memory usage alerts.

📦 Features

🧰 Requirements

⚙️ Setup Instructions

1. 📥 Clone the Repository

git clone https://github.com/Stashchenko/proxmoxbot.git
cd proxmoxbot

1.1 Install Dependencies

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

2. 🔑 Create a Proxmox API Token

3. 📝 Create a .env File

Create a file named .env in the project root:

BOT_TOKEN=YOUR_TELEGRAM_BOT_TOKEN
ALLOWED_CHAT_IDS=123456789,987654321
PROXMOX_HOST=192.168.1.11 # replace to your IP if the PVE host
PROXMOX_USER=botuser@pve # your proxmox bot user
PROXMOX_TOKEN_ID=bot-token
PROXMOX_SECRET=your_secret_here

💡 ALLOWED_CHAT_IDS should contain the Telegram chat IDs of users allowed to use the bot.

To get your chat ID, send a message to the bot and use:

https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates

4. 🚀 Run the Bot

python3 main.py

You should see:

🌐 Webhook server running on port 3001
🤖 Commands initialized successfully
🤖 Telegram bot started successfully
🖥️ Proxmox memory monitor started

🔗 Webhook Integration (Optional)

If you want to receive Proxmox events. On your Proxmox host, configure a webhook pointing to your bot server:

http://<bot_server_ip>:3001/proxmox-webhook

Body:

{"title":"{{title}}","message":"{{message}}","severity":"{{severity}}"}

Test sending a sample webhook — you should see the message in your Telegram chat.

Run as a service (optional)

1. Create the Systemd Service
sudo nano /etc/systemd/system/proxmox-bot.service
2. Paste the following contents:
[Unit]
Description=Proxmox Telegram Bot
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStartPre=/bin/sleep 30
ExecStart=/usr/bin/python3 /root/main.py
WorkingDirectory=/root
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
3. Enable and Start the Service

Reload systemd to recognize the new service:

sudo systemctl daemon-reload

Enable the service to start on boot:

sudo systemctl enable proxmox-bot

Start the service immediately:

sudo systemctl start proxmox-bot

Check the service status:

sudo systemctl status proxmox-bot

Chech logs:

journalctl -u proxmox-bot -f