Telegram is a messaging app with a focus on speed and security, it’s super-fast, simple and free. With Telegram, you can send messages, photos, videos and files and you can create groups. Telegram is like SMS and email combined. Moreover Telegram launched a BOT API and platform for third-party developers to create BOTs. BOTs are simply Telegram accounts operated by software, not people, and they’ll often have Artificial Intelligence (AI) features. They can do anything: teach, play, search, broadcast, remind, connect, integrate with other services and you can interact with Internet of Things (IoT) world.
So a Telegram BOT involve two concepts very very important for me: AI and IoT. From my point of view the AI means IBM Watson and IoT means IBM IoT platform.
The idea is to build an intelligent Telegram BOT using the Watson services to introduce some AI features. For example by Alchemy Language APIs the chat text can be analyze to add high-level semantic information like a Sentiment Analysis, the Emotion Analysis, the Concept Tagging and the Taxonomy Classification. In this way a BOT can understand the sentiments and the concepts express in a chat.
Moreover a Telegram BOT can act as a smart agent for customer support service: by the Watson Retrieve and Rank service the BOT can resolve directly a service request without the human interaction and without a Trouble Ticketing product.
The Watson Retrieve and Rank service together with Sentiment analysis could be a game changer in the customer support service: my idea is that the algorithm can be interact with the user to resolve a service request but when the user’s sentiment is negative a human operator will swap with the algorithm to manage the problem. The user may not understand when he interacts with an algorithm or when he interacts with a human.
The BOT-customer support scenario is so interesting that I will dedicate a separate post in the near feature.
According to me the best way to building intelligent Telegram BOT with IBM Watson is to use node-RED, there are already Telegram BOT nodes for node-RED, in details there are receiver and a sender node which act as a telegram BOT. The only thing required is the token that can be retrieved by the BOTfather telegram BOT during the BOT creation. Here how to create a BOT via another BOT: the BOTFather
You also can implement your BOT using directly the rest-API. After creating my BOT I created my channel for my tests: https://telegram.me/watsonpoc. Attention to subscribe to my channel you might receive many notifications senseless 🙂
In my Proof Of Concept there are two manly scenarios:
- BOT-channel interaction: the channel is used to send news, alerts based on weather forecast, messaging from software products, real-time data from IoT devices and so on. The interaction BOT-channel is mono-directional, currently a BOT cannot read messages send by the other users on the channel.
- BOT-user interaction: the BOT executes commands send from users and it interacts with the user using the Watson services.
An example of first scenario (BOT-channel interaction) is shown by the follow flow, where my BOT send weather forecast on the channel :
Of course I used the IBM insights for weather API, you can read more details here.
Another example of first scenario is shown by the follow flow, where my BOT sends the sensor data to the channel:
To send Internet of Things sensor data can be useful on a private channel, for example associated to own smart-home, real-time data can be send on the “family telegram channel”.
With this approach the Telegram is used to broadcast messages to anyone who joins and currently this is the most common use of a Telegram channel.
The second scenario (BOT-user interaction) represents my personal thoughts about how IBM Watson services can support the classic AI algorithms as text recognition, semantic analysis, and machine learning.
An example of second scenario is shown by the follow flow, where my BOT waits for an user request :
The telegram node waits for user chat, it can manage a conversation by the Dialog services. This service allows to automate branching conversations between an user and your application. The Dialog service enables your applications to use natural language to automatically respond to user questions.
When the user chats a /SR command the Watson Retrieve and Rank is invoked. You can read details here.IBM Watson Retrieve and Rank service helps users find the most relevant information for their query by using a combination of search and machine learning algorithms to detect “signals” in the data. You can load data into the service, train a machine learning model based on known relevant results, then leverage this model to provide improved results to their end users based on their question or query. By this approach a service request can be managed directly by a BOT without a human operator and without a specific trouble ticketing application.
Here a Telegram chat example about an e-mail configuration problem, I trained a machine learning model on this topic for my previous demo :
In this example the solution is the answer with rank position one and it is just sent to the user.
An extension of second scenario is based on the sentiment analysis, see this flow :
a human operator is alerted if the user opens a service request with a negative sentiment. In this case a human friendly, sensitive, empathetic approach can help to manage a hungry user. You can read details about the sentiment analysis here.
I still remember the first IRC BOT, a set of scripts that connects to Internet Relay Chat as a client, and so appears to other IRC users as another user. Today an user cannot recognize if you are talking with a BOT or with a human being 🙂
Building intelligent Telegram bots with IBM Watson is really fun, and it does not end there.
Your Feedback is Welcome.