Telegram Bot
| Feature / Capability | Notify Plugin | Moonraker Telegram Bot |
|---|---|---|
| Requires external server | – | + |
| Remote printer control | – (possible via zmod.link) | + |
| Timelapse creation | – (possible via timelapse) | + |
| Print event notifications (start, pause, cancel, finish) | + | + |
| Filament sensor notifications | + | + |
| Print progress percentage | + | + |
| Multiple printers via a single bot | + | – |
| Notifications via other services | + | – |
| Splooman | - | + |
If you only need notifications in Telegram, then use the Notify plugin
Telegram Bot¶
Description¶
If you only need notifications in Telegram, then use the Notify plugin
Core Idea: Our hardware is very slow and has limited memory. Therefore, running the moonraker-telegram-bot directly on the hardware is impractical. However, we can run it on an external server. This requires any server (physical/virtual) that the printer can reach via SSH.
The new version automatically generates SSH keys (used for passwordless authentication).
Key locations:
/mod_data/ssh.pub.txt— public key. Copy its contents to the server's~/.ssh/authorized_keysfile./mod_data/ssh.key— private key. Used by the printer to connect to the server.
You don’t need the keys themselves. Simply call the ZSSH_ON macro with the following parameters:
SSH_SERVER— IP or hostname of your serverSSH_PORT— SSH port on the server (default: 22)SSH_USER— SSH server usernameVIDEO_PORT— Server port for receiving video stream from the camera (default: 8080)MOON_PORT— Server port for receiving data from moonraker (default: 7125)REMOTE_enN— Command to execute on the remote server
SSH usage consumes approximately 300 KB of memory.
If the printer and server are on the same network, SSH is optional. Refer to the telegram.conf configuration file.
Download the configuration file from the printer at mod/telegram/. Sample-config
Bot Registration¶
How to register your bot:
- Go to @BotFather
- Send
/newbot - Enter any name you like
- Enter the bot name (must end with
_bot, e.g.,ff5msuper_bot) - You’ll receive a long ID — add this to the bot’s
bot_tokenparameter in the settings.
Server Deployment¶
One-Command Telegram Bot Installation on Debian¶
If you only need notifications in Telegram, then use the Notify plugin
Install the Telegram bot with one command on Debian:
Execute as the root user:
bash <(wget --cache=off -q -O - https://github.com/ghzserg/zmod_ff5m/raw/refs/heads/1.6/telegram/telegram.sh)
If wget is not installed:
apt update && apt install wget -y
This script will:
- Install Docker
- Download docker-compose.yml and telegram.conf Sample-config
- Create a
tbotuser - Guide you through bot registration and request the
bot_token - Guide you to obtain the
chat_idand request it - Install ff5m.sh
Add SSH keys manually.
Step-by-Step Telegram Bot Installation¶
If you only need notifications in Telegram, then use the Notify plugin
- Copy docker-compose.yml from the printer’s
mod/telegram/directory. -
Install Docker (Debian instructions):
apt update apt upgrade -y apt install docker.io docker-compose docker apparmor -y -
Create a directory for the bot:
mkdir bot1 cd bot1 -
Place docker-compose.yml here.
-
Create subdirectories:
mkdir config log timelapse_finished timelapse chmod 777 config log timelapse_finished timelapse -
Copy telegram.conf from
mod/telegram/toconfig/and edit it.
For more bot configuration details, see here.
-
Start the bot:
docker-compose up -d -
Create a user and grant permissions:
useradd tbot usermod -a -G docker tbot
Adding SSH Keys¶
-
Log in as the
tbotuser:su - tbot -
Add SSH keys:
Paste the public key frommkdir .ssh cat > .ssh/authorized_keysmod_data/ssh.pub.txt, then pressCtrl + D.
Starting ZSSH on the Printer¶
After setup, run the ZSSH_ON macro on the printer with the required parameters.
SSH will automatically restart 3 minutes after each reboot.
Spoolman¶
Edit the docker-compose.yml file.
Add:
spoolman:
image: ghcr.io/donkie/spoolman:latest
restart: unless-stopped
volumes:
- ./spoolman:/home/app/.local/share/spoolman
ports:
- "7912:8000"
environment:
- TZ=Asia/Yekaterinburg
Open the port in the firewall, if you are using one:
iptables -I INPUT -p tcp --dport 7912 -j ACCEPT
Create the spoolman directory:
mkdir spoolman
chmod 777 spoolman
Restart Docker:
docker-compose down && docker-compose up -d
docker compose down && docker compose up -d
On the printer, add to mod_data/user.moonraker.conf
external_IP — the external IP address of the server running Docker.
The printer MUST have access to this IP.
[spoolman]
server: http://external_IP:7912
sync_rate: 5
TimeZone¶
Edit the file docker-compose.yml
Specify your time zone. The example file specifies TZ=Asia/Yekaterinburg
docker-compose down && docker-compose up -d or docker compose down && docker compose up -d
Installation and Setup for Armbian (by noyhay)¶
If you only need notifications in Telegram, then use the Notify plugin
Download Debian Minimal/IOT images with Armbian from the website https://www.armbian.com/download/
Install Armbian on an SD card using balenaEtcher from https://etcher.balena.io/
Boot the system, set a root password, and create a new user
Proceed under the root user:
su - root
Configure Wi-Fi if not set up during user creation:
sudo armbian-config
Update the system:
sudo apt update && sudo apt upgrade -y
Install AppArmor (Linux kernel security module):
sudo apt install -y apparmor apparmor-utils
Install Telegram bot:
bash <(wget --cache=off -q -O - https://github.com/ghzserg/zmod_ff5m/raw/refs/heads/1.6/telegram/telegram.sh)
Add SSH keys:
Switch to the tbot user from root:
su - tbot
Set up SSH keys:
mkdir -p .ssh
cat > .ssh/authorized_keys
mod_data/ssh.pub.txt on your host system, then press CTRL+D
Reboot the system:
sudo reboot
Telegram Bot Installation On Kubernetes Via Helm (by aldiserg)¶
If you only need notifications in Telegram, then use the Notify plugin
Download and install helm https://helm.sh/docs/intro/install/
Clone helm chart from repo
git clone https://github.com/aldiserg/zmod_ff5m_tg_bot.git
-
persistence.enabled change to "false" if you nont planned to store timelapses
-
persistence.volumes...storageClass change if you will use external storage
-
configMapAsFile.data.telegram.conf - this is main config file, should be changed a few lines:
How to get bot_token and chat_id look here[bot] server: 3D_printer_host:7125 bot_token: 1111111111:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA chat_id: 111111111 [camera] host: http://3D_printer_host:8080/?action=stream host_snapshot: http://3D_printer_host:8080/?action=snapshot
Installation:
You should be in helm chart folder to run install/upgrade command
helm upgrade --install zmod_ff5m_tg_bot ./ -n default -f values.yaml