Bots for Business

A Guide to Building Bots for Telegram

Widely known as a secure messaging application, Telegram Messenger is also a bot-friendly platform. Using the Telegram Bot API, you can make your bot available to the platform’s 200 million active users. Because of its privacy-first ethos, Telegram may be an excellent platform for bots that process sensitive data.

July 30, 2019
telegram messenger app and tools to build a chatbot

Launched initially as a messaging app focused on privacy and security, Telegram Messenger offers users an encrypted communication channel. According to Telegram company literature, the messages you send (or receive) on the app are subject to rigorous privacy standards and cannot be read or accessed by anyone other than an intended recipient—and that includes Telegram itself.

What does all that privacy have to do with building Telegram bots? Quite a lot, actually.

Why build a Telegram bot?

Telegram Messenger’s biggest media moment occurred when it was banned in Russia. Citing its commitment to user privacy, Telegram refused to allow government monitoring of citizens’ conversations on the platform. In response, the Russian government secured a judicial ruling that barred the use of the messaging app.

Unsurprisingly, these efforts ended up highlighting the app’s privacy standards—a benefit you can capitalize on with your chatbot. Although there’s some debate over Telegram’s encryption standards and whether they live up to their claims, the general perception of Telegram is that it’s a secure platform. Telegram users trust that their communications are private, which means you could find a ready audience for chatbots that process sensitive information. Banking bots are one example, and cryptocurrency-focused bots abound on Telegram.

Telegram Messenger has around 200 million monthly active users, so you’ll likely find an audience there that suits your business goals. It is also very popular in Central Asia and parts of Africa, so it could be a fruitful platform if you’re building an app for users in those regions.

How to make a Telegram bot

Telegram actually has a bot for making bots. It’s called BotFather. Start by chatting with BotFather, tell it the name of your bot, and create a username for it. BotFather will generate a token that authorizes your bot and lets you send HTTPS requests to the Telegram Bot API.

There are additional BotFather-specific commands you can enter to do things, like edit your bot’s description and modify bot settings (the basic setup process). Going through these steps allows you to get your bot onto Telegram.

As for the actual details of your chatbot itself, you need to build it using a bot framework. In most cases, a framework enables you to build your bot and deploy it to many different channels, such as Telegram, Facebook Messenger, and even your own site.

Although you can use any framework you want and connect your bot to Telegram via the Bot API, Dialogflow and Botpress are two chatbot frameworks that can provide seamless Telegram integration. Just provide your token in the framework interface, and start talking to your bot on Telegram.

How to integrate your bot with Telegram Messenger

Here’s how Telegram bot integration works with Botpress:

  1. Create your bot using BotFather.
  2. Locate your Telegram bot token.
  3. Navigate to Telegram-specific JSON file within Botpress.
  4. Find the line for your bot token, and paste or enter it.
  5. Restart Botpress, and test out your bot in Telegram.

Pretty simple, right? The process for integrating a Telegram bot with Dialogflow is similar. However, instead of navigating to a specific JSON file, there’s a GUI for entering your bot token.

Building with either of those frameworks is probably the easiest way to integrate your bot with Telegram, but there are other ways. This tutorial shows you how to integrate a bot hosted on AWS Lambda with Telegram, and the process is only slightly more involved than with Dialogflow or Botpress. Another Telegram tutorial shows you how to integrate a bot built using IBM Watson Assistant.

When you integrate your bot with Telegram, be sure you also deploy it to a dedicated domain. Securing a bot-centric domain for your bot, such as a .BOT domain, is always a good idea since users come and go from different messaging apps. With a dedicated domain, your bot has a “forever home” on the web.

Telegram Messenger chatbot examples

There are countless bots on Telegram, ranging from fun and convenient to efficient and practical. Gaming bots, meme-producing bots, joke bots—you name it. Telegram has something for everyone.

However, the most compelling bots on Telegram may be those that process sensitive information. Security and privacy, after all, are its hallmarks, and there are lots of bots that ingest private data.

Just keep in mind, when you’re building bots, that Telegram doesn’t use the same encryption protocol for bots that it uses for other chats. Curiously, communication with your bot is less secure than communication occurring strictly among humans using Telegram. If your bot handles sensitive data, you may need to apply an additional layer of security on top of the Telegram defaults.

Cryptocurrency chatbots

There are several cryptocurrency bots on Telegram. XirkleBot is one of them, and it provides quick and easy access to your wallets for different currencies. Popular currencies like BTC, BCH, ETH, LTC, XLM, and XIR are all supported.

For anyone who needs to keep a constant eye on Bitcoin prices, there’s Bitcoin Price Bot. This chatbot notifies you of the current price of BTC with a message in Telegram.

If you need even more updates about the fluctuation of BTC or want a bigger-picture cryptocurrency newsfeed, there’s Blocky. Users engage with Blocky for live price updates, market data, trending cryptocurrency news, and additional information.

Privacy chatbots

Sometimes you need an email address to sign up for services, but you don’t want to receive marketing communications at that address. In those situations, rather than using your primary email address, you can get a temporary one at Vanish Mail.

If you have cryptocurrency and want a way to passively monitor the value of your Ethereum addresses, the MyETH bot can do that for you. MyETH notifies you in Telegram whenever there’s a movement of ETH or ERC20 tokens.

Communication chatbots

We’ve all been unsure about what to say in awkward situations. Honey Waffle is a Telegram chatbot that uses AI to help you respond appropriately in delicate situations. You can ask the bot for advice on touchy topics you’re discussing with family and friends, like writing an apology or telling someone your true feelings.

For less serious conversations, there’s Message Wiz. If you’re goofing off, need to make your friends laugh, or just want to sound silly, this chatbot translates your humdrum messages into slangy text-speak. With Message Wiz, a statement like, “This is a cool bot,” might become something like, “Dis is a rL Ql bot!” Is it silly? Sure. But that’s the whole point.

Getting started with Telegram bots

The Telegram Bot API manual is the best place to learn about how your bot behaves on the platform. The app’s Intro to Bots tutorial also provides useful background information about some of Telegram’s unique traits. For example, it contains a review of the different types of keyboards available to users as they interact with your bot. Having an understanding of these options will help you design bot dialogue in a way that makes sense for Telegram users.

After that, you’re ready to start building! Telegram is a bot-friendly platform with a well-documented API and straightforward onboarding procedures.