RepositoryGo
xDWart

xDWart/mqtg-bot

MQTT Client Telegram Bot

103stars
22forks
4issues
1views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: iot-gateway

#1 Repository of the month

1
TINIX TRENDING·Topic: iot-platform

#1 Repository of the month

1
TINIX TRENDING·Topic: iot-cloud

#1 Repository of the month

mqtg-bot

Build Status Go Report Card Version License

Gopher Bot

Articles

Introduction

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.

Edit buttons menu

Temp and Humidity

Take a picture

Features

  • 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)

Usage

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.

Environment variables

  • TELEGRAM_BOT_TOKEN - bot HTTP API access token, required
  • DATABASE_URL - Postgres connection string in the following format: postgres://user:password@host:port/db
  • SQLITE_PATH - path to SQLite database
  • MQTT_CLIENT_ID - Client ID to be used. Required for VerneMQ.

Notes:

  1. Only TELEGRAM_BOT_TOKEN env is required
  2. If DATABASE_URL env is omitted, or a Postgres connection error occurred, SQLite will be used
  3. If SQLITE_PATH env is omitted, mqtg.db will be used by default as a SQLite database
  4. You can create the .env file in the root of the project and insert your key/value environment variable pairs in the following format of KEY=VALUE

Local running

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

Running in Docker container

docker run -e TELEGRAM_BOT_TOKEN=... -e DATABASE_URL=... --network=host owart/mqtg-bot

Heroku running

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.

Contribution

Licence

  • mqtg-bot is licensed under the MIT License.
  • See LICENSE for the full license text.
  • Copyright (c) Anatoliy Bezgubenko

Similar Projects

Discover other similar projects and AI models.

RepositoryGo
absmach/magistrala

IoT Platform Framework

2.7k
Nov 23, 2026
RepositoryGo
avelino/awesome-go

A curated list of awesome Go frameworks, libraries and software

197.2k
Dec 2, 2026
RepositoryGo
ollama/ollama

Get up and running with Inkling, Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

188.9k
Dec 2, 2026
RepositoryJava
thingsboard/thingsboard

All-in-one IoT Platform - Device management, data collection, processing and visualization.

22.7k
Nov 30, 2026
RepositoryC
eclipse-mosquitto/mosquitto

Eclipse Mosquitto - An open source MQTT broker

11.5k
Nov 19, 2026
RepositoryJava
jetlinks/jetlinks-community

JetLinks 基于Java,Spring Boot ,WebFlux,Netty,Vert.x,Reactor等开发, 是一个全响应式的企业级物联网平台。支持统一物模型管理,多种设备,多种厂家,统一管理。统一设备连接管理,多协议适配(TCP,MQTT,UDP,CoAP,HTTP等),屏蔽网络编程复杂性,灵活接入不同厂家不同协议等设备。实时数据处理,设备告警,消息通知,数据转发。地理位置,数据可视化等。能帮助你快速建立物联网相关业务系统。

6.7k
Nov 26, 2026
RepositoryTypeScript
emqx/MQTTX

A Powerful and All-in-One MQTT 5.0 client toolbox for Desktop, CLI and WebSocket.

5.1k
Nov 30, 2026
RepositoryC#
dotnet/MQTTnet

MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). The implementation is based on the documentation from http://mqtt.org/.

5.1k
Nov 27, 2026
RepositoryGo
golang/go

The Go programming language

140.0k
Dec 1, 2026