Weather Bot - Dokkaebi Example

Recently, I created a practical demo that shows how to use some of the Dokkaebi library's functionality. You can find and test drive the live bot on Telegram by the name @WeatherVaneBot.

Design

WeatherVaneBot was designed simply to take a command from the user and return some weather information to the Telegram client in the form of a message.

How it Works

A chat member may invite @WeatherVaneBot to a chat either by clicking the link shown here or by searching for the bot by name in the Telegram client. Once they do one of those things, they may send WeatherVaneBot the following commands:
  • /start
  • /help
  • /cityweather [CITYNAME]
  • /zipweather [POSTAL CODE]
  • /dash [CITYNAME]
For example, see a conversation:

bot conversation

Weather Dashboards

A chat member may also request a weather dashboard from @WeatherVaneBot via chat by issuing the /dash command, for example:
/dash san diego
Once the chat member invokes the command, @WeatherVaneBot will send a link to the chat taking them to the weather dashboard. A result similar to that found below will be shown to the chat member upon clicking the link generated in Telegram:

dashboards

Development

@WeatherVaneBot is an example program that is co-developed with the Dokkaebi library. It demonstrates the capabilites of the Dokkaebi Telegram Bot API wrapper including taking commands from chat members and returning useful weather data in the form of a message. The weather data itself is culled from OpenWeatherMap which provides developers with API keys on demand. In addition, the maps generated in weather dashboards are created using a combination of Leaflet and Mapbox.

Once you follow the steps to create a bot with the BotFather, the only requirement to run the weather bot is a computer to run the app (on a local laptop/PC or deployed to a server) and some configuration parameters set in a single .ini file. For example:
[Telegram]
BOT_TOKEN = YOURBOTTOKEN
PORT = 80
HOSTNAME = 127.0.0.1
WEBHOOK_URL = https://yourwebhookurl.com
ENVIRONMENT = test_suite
[OpenWeather]
API_KEY = YOURKEY
[Mapbox]
API_KEY = YOURKEY
The original example contains around 200 lines of code. This demonstrates the simplicity of using the API wrapper at a low level, integrating it with existing web services such as OpenWeatherMap. While the official @WeatherVaneBot uses everything in the original example plus some extras to create a somewhat more useful application for Telegram chat members. You can find the source code of the original 200-line example on github. The continuing development of the official @WeatherVaneBot can be followed at its own repository as well.