Telegram recently released a new Bot API, which makes it relatively easy to integrate with applications like GitHub Hubot.

I recently collaborated on an adapter for Hubot that makes the integration trivial.

Register A Bot With BotFather

First thing you need is a Telegram Bot, which you can easily register using their BotFather application. You need to add the BotFather to your Telegram application and create a new bot by typing /newbot and following the instructions, this will result in a token that you will use later when executing your bot.

Configure The Hubot Instance

In order for Hubot to work, you will need to install NodeJS and NPM. When you have installed those dependencies, you can set up a new default Hubot by running the following commands:

npm install -g yo generator-hubot
mkdir myhubot
cd myhubot
yo hubot --defaults

You can test your Hubot by typing bin/hubot which will launch a CLI version of Hubot for testing. You now need to install the Telegram dependency, you can do so by running:

npm install --save hubot-telegram

This will download the source code and add it to your package.json file in the Hubot directory.

Note: If Hubot is not available under bin/hubot you can try and run it from the Hubot folder with ./node_modules/.bin/hubot.

Running Hubot

Now that you have everything configured and installed, you can start your Hubot instance with the following command:

TELEGRAM_TOKEN=<token> bin/hubot -a telegram -n botname

If everything has been configured correctly, the bot should start up and announce itself based on the name you gave it when you created it on Telegram. To get started type @botname help in a chat with your bot, this will produce a list of available Hubot commands. You can add more commands to Hubot by following some of the instructions on their site.

Note: The botname you specify should be the same as your Telegram bot name for a consistent and predictable experience.