Although this is based on https://github.com/pskillen/meshtastic-bot I have personalised it a lot to my own setup for commands, auto replies and automations etc
I am now working on Node-totals which I hope to be able to report the number of nodes my remote nodes can see.
Meshtastic Bot is a Python-based bot for interacting with Meshtastic devices. It listens for messages, processes commands, and responds with appropriate actions. This guide is focused on helping you run the bot as-is, with minimal setup.
The easiest way to run Meshtastic Bot is using Docker. This method requires minimal setup and keeps your environment clean.
- Ensure you have Docker and Docker Compose installed.
- Create a
.envfile in your project directory with the required environment variables:
MESHTASTIC_IP=your_meshtastic_node_ip
ADMIN_NODES=comma_separated_admin_node_ids
STORAGE_API_ROOT=https://meshflow.pskillen.xyz
STORAGE_API_TOKEN=your_storage_api_token from above site
# Optionally, you can upload to a second API as well
STORAGE_API_2_ROOT=your_storage_api_2_url
STORAGE_API_2_TOKEN=your_storage_api_2_token
# Feature Toggles
ENABLE_TCP_PROXY=true
# Command Toggles (set to false to disable)
ENABLE_COMMAND_PING=true
ENABLE_COMMAND_TR=true
ENABLE_COMMAND_HELLO=true
ENABLE_COMMAND_HELP=true
ENABLE_COMMAND_NODES=true
ENABLE_COMMAND_WHOAMI=true
ENABLE_COMMAND_PREFS=true
ENABLE_COMMAND_ADMIN=true
ENABLE_COMMAND_STATUS=true
services:
bot:
image: ghcr.io/pskillen/meshtastic-bot:latest
container_name: meshtastic-bot
restart: unless-stopped
env_file:
- meshtastic-bot.env
volumes:
- mesh_bot_data:/app/data
volumes:
mesh_bot_data:docker compose up -dThe bot will now run in the background. Data will be persisted locally in the mesh_bot_data Docker volume.
You can enable or disable specific features and commands using environment variables in your .env or meshtastic-bot.env file. All options default to true if not specified.
ENABLE_TCP_PROXY: Set tofalseto disable the internal TCP proxy. The bot will connect directly toMESHTASTIC_IP.PROXY_HANDSHAKE_CACHE_SIZE: Number of initial packets to cache for connecting proxy clients (default100).PROXY_ROLLING_CACHE_SIZE: Number of recent packets to cache in a rolling queue for connecting proxy clients (default100).
Set any of the following to false to disable the command and hide it from the !help menu:
ENABLE_COMMAND_PINGENABLE_COMMAND_TRENABLE_COMMAND_HELLOENABLE_COMMAND_HELPENABLE_COMMAND_NODESENABLE_COMMAND_WHOAMIENABLE_COMMAND_PREFSENABLE_COMMAND_ADMINENABLE_COMMAND_STATUS
There are two primary ways to run the bot using Docker:
- Purpose: Stable use with local source control.
- How it works: It builds the bot locally from the source files in the repository.
- Includes: Integrated Watchtower service which automatically checks for and applies updates to the
meshtastic-botcontainer every hour. - Environment: Configuration is pulled from your
.envfile.
- Purpose: Quick deployment using the official container.
- How it works: Pulls the pre-built image from the GitHub Container Registry (
ghcr.io). - Configuration: Uses
meshtastic-bot.envfor environment variables and a named Docker volume (mesh_bot_data) for persistence.
If you prefer to run the bot natively (e.g., for development or customization):
- Clone the repository:
git clone https://github.com/yourusername/meshtastic-bot.git cd meshtastic-bot - Install dependencies:
pip install -r requirements.txt
- (Optional) On Raspberry Pi:
sudo apt-get install libopenblas-dev
- Configure environment:
- Copy
.env.exampleto.envand fill in the required values.
- Copy
- Run the bot:
python main.py
The bot listens for messages and responds to commands as a direct message. You can interact with it via supported Meshtastic channels.
| Command | Description |
|---|---|
!help |
Displays a list of available commands |
!hello |
Displays information about the bot |
!ping |
Responds with "Pong!" |
!nodes |
Displays a list of connected nodes, stats, etc |
!nodes totals |
Manually triggers a node count report |
!whoami |
Displays information about the sender |
!tr |
Performs a traceroute to the sender (outbound & inbound) |
!status |
Displays bot status and radio connection details |
The bot monitors mesh visibility and provides automated reporting:
- Scheduled Reports: Every 3 hours, a status update is sent to Channel 2 (GregPrivate) with the current online node count.
- Immediate Alerts: If the visible node count drops to zero, the bot sends an immediate warning.
- Manual Check: Use
!nodes totalsto get an instant report via DM.
The bot now includes a built-in TCP proxy to manage the connection to the Meshtastic node. This improves stability and allows for automatic reconnection if the radio connection is lost.
Messages received on named Group Channels (e.g., 'LongRange', 'PrivateChat') are now logged with their specific channel name, making it easier to track conversations across different mesh networks.
The !tr command has been upgraded to show the full path:
- Outbound: The route from the bot to your node.
- Inbound: The route back from your node to the bot (if available).
If you want to add new commands or responders, see the src/commands/ and src/responders/ directories. The codebase is structured for easy extension, but most users will not need to modify the code to run the bot.
- Commands: Add new command classes and register them in the command factory.
- Responders: Inherit from
AbstractResponderto handle public channel messages.
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License.