Development of the Open-Source Telegram Bot for MQTT IoT

Development of the Open-Source Telegram Bot for MQTT IoT

Experience of development a flexible and an easy-to-configure for your needs open-source MQTT client Telegram bot. Obtaining information and controlling IoT devices via the MQTT protocol.

Experience of development a flexible and an easy-to-configure for your needs open-source MQTT client Telegram bot.

Today I will be sharing my experience in developing a flexible Telegram-bot. His purpose: obtaining information and controlling IoT devices via the MQTT protocol.

What’s so special? Because this is not just a bot with two-three hardcoded buttons to operate a light bulb (there are many examples of that on the Internet), but a bot that supports flexible subscriptions and commands to operate directly from the menu, without any changes introduced to the source code. It’s a ‘NoCode solution’, so to speak.

The bot is based on Go and the source code is made freely available on GitHab under MIT license. In this article, I’m talking about some technical aspects of implementation and the resulting functionality with usage samples.

What for?

Several factors have been pieced together. First of all, I have long wanted to transfer my  smart intercom (sorry, it’s in russian) to something lighter and more universal than IoTManager. One Telegram-bot covers the entire multitude of devices and operating systems. Leave compatibility issues to comrade Durov. At last, I can open the intercom from my laptop.

Secondly, I really wanted to practice bot-writing, and I am very attracted to the very idea of managing something by means of a messenger. This is how Vas3k in his club made an admin panel via Telegram, isn’t that cool?

Functionality

Writing a bot with a few hardcoded buttons is tedious. I decided to make a more versatile solution with a customized user menu and display graphics support.

The following functionally was the basic goal:

  1. Multi-level user menu with the possibility of creating the following buttons: folder (for tree-like menu), single-value-command button, toggle button, multi-value-command button, show the last message received for the topic, draw chart
  2. Subscription to arbitrary topics (including receiving images)
  3. Storage of value history
  4. Manually sending a message to the topic

All the functionality is available directly from the bot menu without the need to change the source code. Edit the menu on the go and use it:

mqtg

You can give a try to my copy of the bot at  @mqtg-bot. Notice that there may be some crashes because he is deployed on the free Heroku dyno. If he doesn’t respond to /start, now you know the reason. You can run your bot by consulting the README instruction.

golang telegram

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Hire Dedicated Golang Developers | Golang Web Development Company

Hire dedicated GoLang developers from WebClues Infotech to build applications using Go language. Get best GoLang developers for your web development projects.

Telegram Clone | White Label Telegram Like App Development

Launch a message app like Telegram by subscribing to our white label Telegram clone app development service.

Golang Web Development:Th Best Programming Language in 2020

Golang Web Development is the new trend globally. Get all the details about the Golang development here. Hire Golang Developers.

Creating an Image Recognizer on Golang Telegram Bot

In this lesson, we are going to learn how to Creating an Image Recognizer on Golang Telegram Bot. We will go over a project on image recognition using Go. We will also create a Telegram bot, through which we can send images for recognition.

Telegram and Bot (Part 1)

A bot to do your regular tasks… Introduction to Bot and Bot API