- Development of the Open-Source Telegram Bot for MQTT IoT (En, DZone.com)
- (Не)очередной MQTT-телеграм-бот для IoT (Ru, Habr)
- Разработка NoCode решения для интернета вещей (Ru, YouTube)
mqtg-bot is an easy-to-configure for your needs MQTT client Telegram bot. Without programming knowledge you can configure the bot to send various commands (turn on the light, open the garage door, etc.) or request any information (the temperature in the house, the state of the heating system, etc.) or receive frames from security camera. In general the functionality of this solution is very rich.
- Dockerfile using clearlinux:latest for glibc and SQLite support
- Connecting to MQTT broker
- tcp / ssl / ws / wss
- Supported databases
- Postgres
- SQLite
- Subscribing to a topic:
- Selectable QoS/Retained
- Text/Image data types
- Pre/post value displaying text
- Storing data into DB
- Parse data by JsonPath expressions
- Data storage management
- Publish action on receiving
- Voice data type
- Publishing to a topic:
- Selectable QoS/Retained
- Text/Image data types
- Voice data type
- Customized users buttons menu:
- Folders
- Single-value buttons
- Toggle buttons
- Multi-value buttons
- Print last subscription value
- Draw charts
- Your great idea (create a proposal in issues)
You can run the bot on your Raspberry Pi home server or free Heroku dyno.
Clone this repository:
git clone https://github.com/xDWart/mqtg-bot
Message @BotFather /newbot
command to create a bot and get his HTTP API access token.
TELEGRAM_BOT_TOKEN
- bot HTTP API access token, requiredDATABASE_URL
- Postgres connection string in the following format:postgres://user:password@host:port/db
SQLITE_PATH
- path to SQLite databaseMQTT_CLIENT_ID
- Client ID to be used. Required for VerneMQ.
Notes:
- Only
TELEGRAM_BOT_TOKEN
env is required - If
DATABASE_URL
env is omitted, or a Postgres connection error occurred, SQLite will be used - If
SQLITE_PATH
env is omitted,mqtg.db
will be used by default as a SQLite database - You can create the
.env
file in the root of the project and insert your key/value environment variable pairs in the following format ofKEY=VALUE
You can run mqtg-bot with environment variables:
TELEGRAM_BOT_TOKEN=... go run main.go
or if you've already created the .env
file:
go run main.go
docker run -e TELEGRAM_BOT_TOKEN=... -e DATABASE_URL=... --network=host owart/mqtg-bot
You will need Heroku CLI
# login into Heroku
heroku login
# create a new app
heroku create *YOUR_APP_NAME*
# add your new app into git remotes
heroku git:remote -a *YOUR_APP_NAME*
# add TELEGRAM_BOT_TOKEN environment
heroku config:set TELEGRAM_BOT_TOKEN=*BOT_ACCESS_TOKEN*
# set version of Go
heroku config:set GOVERSION=go1.15
# attach Postgres add-on
heroku addons:create heroku-postgresql:hobby-dev
# push master branch to Heroku
git push heroku master
# scale up your app
heroku ps:scale worker=1
Then just message /start
to your bot and follow the instructions to configure it.
- Do you have an idea to improve mqtg-bot? -> Create an issue.
- Have you discovered a bug? -> Create an issue.
- Have you already coded something for mqtg-bot? -> Create a pull request.
- mqtg-bot is licensed under the MIT License.
- See LICENSE for the full license text.
- Copyright (c) Anatoliy Bezgubenko