Caretaker Telegram Chatbot

Chatbots are a relatively new entity in the digital space and they only got popular because of platforms like Telegram which allow for programmers to easily make their own bots using external libraries and their API (application programming interface). Telegram itself is quite a popular messaging service and so we felt that the idea of a caretaker for Binmax using a chatbot on Telegram was within the realm of possibility. It was also much more achievable than to create an entire mobile application for the caretaker or to use a messaging service such as Twilio which is paid to contact the caretaker. One could also send an email, but we felt that emails were too formal and are not as interactive as we would want it to be.

Requirements

We identified the following requirements for the bot:

  1. Able to check how full the bins were
  2. Able to authenticate oneself as the caretaker since the bot was publicly available and limit functionality to caretakers only

Library Used

We used the Telethon library to create our bot. The more popular choice was python-telegram-bot but the prerequisites for the library was not available for the hardware architecture of the Jetson Nano while Telethon was compatible.

Software

We had to first contact the bot @BotFather on Telegram which is Telegram’s bot manager bot (yes, a bot that manages bots) to generate a unique token key for us to use for the bot. Then we coded in the commands:

  • /start – to start the bot for the user
  • /auth- to authenticate the user with a password
  • /checkfill – to check how full the bins were
  • /checkcamera – to check the last capture image on the camera

The authenticate command checks whether the characters that come after the /auth command is equal to a preset password and if it is, it would store the unique ID number of the user into a dictionary as the key and ‘True’ as the value.

/checkfill and /checkcamera will always check whether the user’s ID is in the dictionary and whether the value is equal to ‘True’. Only if the value is ‘True’ would the commands continue to function.

/checkfill, after confirming the user is authenticated, calls the distance function on the ultrasonic sensors pointing downwards to the bins to get the distance and calculate how full the bins are.

Video Demo

Leave a Reply

Your email address will not be published. Required fields are marked *