The Xatkit family is proud to present its new baby: the Telegram connector! With our new Telegram support, you can now easily create Telegram bots in Java. And not just simple bots, bots that can benefit from all the features of Xatkit to add powerful NLP capabilities or combine Telegram with other platforms.
Our Telegram connector is built on top of this Java wrapper for the Telegram API. Internally, the connector relies on Long Polling to receive the Telegram updates. When in a private chat, the bot will respond to text messages and commands. Internally, commands are treated as regular text inputs by just removing the initial ‘/’ symbol. For bots in groups it’s better to stick to commands only as, by default, the bot will not react to any other types of messages (as per Telegram policies). If you want to configure the bot to be a more active part of the group conversation then you may also set the
ignore fallback parameter to make sure the bot doesn’t try to understand everything people chat in the group and just reacts to messages it’s able to match.
These updates are internally processed and transformed to Xatkit intents by the
TelegramIntentProvider. As usual in our Xatkit infrastructure, once available as Intents, they can be processed as any other intent, regardless of the platform they came from, facilitating the development of platform-agnostic bots (or bots that receive and send events and messages from/to different platforms).
Bot replies are sent back to the Telegram Chat where our bot is participating. Replies can be simple text messages to which the user can reply openly, or they can also include a predefined set of buttons or limited set of reply options. In this latter case, the
TelegramPlatform will embed a custom ReplyKeyboard that will pop up a set of buttons for the user to click on.
To get your Telegram Bot working, there are only two mandatory parameters:
- The Telegram token used by Xatkit to interact with the Telegram API. You can get a token via the BotFather service
- The username of your Telegram bot
Then, you can define your bot as usual. You just need to remember to indicate that the bot will be working with the telegramPlatform and the telegramIntentProvider.
val botModel = model()