📜 ⬆️ ⬇️

Bots in the city of Innopolis

Talk about how to quickly create several useful services for managing the city through bots in Telegram.


Less than 3 months ago, Innopolis officially opened in the Republic of Tatarstan - the first Russian city that appeared in the 21st century.

Its feature is an economy based on high-tech industries and, above all, on IT: the key points of attraction to the city are Innopolis University - siliconrus.com/2015/09/innopolis-student/ and the eponymous special economic zone: innopolis.ru/ sez / investoru

The promising master plan of the city is designed for 155 thousand inhabitants in 15 years, and today about 400 students and a couple of hundreds of permanent residents live in it.
')
image

Like all startups, a start-up city begins with several hundred residents-followers, to whom the city mayor’s office pays special attention. Such a small number has its advantages: for example, all residents of the city, as well as decision-makers about the development of Innopolis, are at a distance of one “tapa” in Telegram. This method of communication was not chosen by chance, but just for promptness and receiving feedback from residents of the city without intermediaries.

Today, a common chat in Telegram unites almost all residents and key employees of the city tjournal.ru/p/innopolis-telegram . It began as a fludilka, but over time it began to be used as the main service: informing, collecting complaints and suggestions from residents, searching for fellow travelers, communicating with like-minded people, all this happens through Telegram. At the same time, only on chat rooms it does not end there: the start-up city Innopolis requires an agile approach in creating services for its inhabitants. And where there is agile, there is MVP, in other words, the minimum benefit to the end user, which can be created with the service with minimal time for the first release. Telegram bots are best suited for MVP implementation.

Boat Concierge Service

Any person on planet Earth can call at 4 am (or any time of the day) the Innopolis Concierge Service at 8-800-222-22-87 and find out about the transport schedule, vacancies in the city, where to buy medicines - about anything. Well, or complain! It is clear that for the most part the residents ask standard questions, and this can be turned into an automated service. And in order for each resident to be aware of all changes, the service must not only provide information on request, but also be able to announce the latest information on their own.
The project developer Yuri Chernushenko solved this problem:

The best analogy for bots will be information concierge services via chat.
Knowing the name of the bot, users create a chat with it in their client program. A bot can provide the interest of quick access to frequently asked questions, redirect messages to the operator and initiate communication by making announcements.

The advantages of this approach include:
• No need to install additional applications, and business to develop and maintain them;
• Communication with users can be automated by a set of prepared responses, thus reducing the call center load;
• Users will be able to receive information to frequent requests in one click
• Business receives all user access statistics;
• Ability to process natural languages ​​(Natural Language Processing), allows you to automate the communication of users in a free form and predict their behavior.

The first time the idea of ​​automating concierge services appeared during Yandex Tolstoy Camp, then we tried to make an analogue of Magic (http://www.getmagicnow.com/) and Luka (https://luka.ai/). At that moment, it seemed that the messengers would move along a closed path and did not open their API to work with them and access the data, so we looked at the good old SMS messages. There were workarounds and unofficial libraries for the same WhatsApp and Telegram, but it was risky to build their solutions based on this approach. Then, unexpectedly, Messenger Facebook and, then, Telegram opened their API and, I think, these platforms will allow you to create many interesting applications.
What can a bot.
The bot consists of two parts: user and operator.

imageimage

Users can set text commands, use quick access buttons to the information or ask free-form questions that are redirected to the operator.

The operator can update the messages hidden behind each button (mainly schedules), and make announcements for users.

This is a simple functional, in part, it even exists in the Telegram itself (broadcast list, for example), but the ability to work with a large number of users, save this information and provide the prepared answers makes the option with the bot more convenient.

What's next

In the concierge bot project, it is interesting to add functionality related to geolocation, since knowing the location of a resident of Innopolis, one can understand a lot about the context of the situation. Also, when the database of user requests is large enough, you can try connecting NLP engines (http://wit.ai/ or tech.yandex.ru/tomita ) to automate communication with the operator.


Bot hack to increase the group limit

Imagine the town square. And you can go out on it and say something important or just flaming, captivating the townspeople with a new idea or discuss the burning one. On the one hand, a city with the speed of thought instant messaging is beautiful, but on the other hand, there is a “curse” in it. The limit of one group in the Telegram - 200 people. And those who want to communicate on the “square” is nearing 400, what to do? That is: the gate forward messages between groups.
One of the developers of CrazyPit talks about the project:

As part of the summer school at Innopolis University, we decided to work with telegram bots. For three weeks we made a prototype framework on Scala using Akka to create telegram bots and wrote several useful bots on the framework.

We managed to create an API that allows you to write bots in “10 lines” and work asynchronously using Akka, as well as the ability to run multiple bots in one process. We plan to add different strategies for parallelizing the work of bots, more complex functions that facilitate the work with the API and DSL to set the bot behavior based on consecutive questions and answers.

Framework repository: github.com/CrazyPit/botspot

A bot that is already working with might and main is a bot uniting groups that do not fit into the limit of 200 people. Although there is information that this limit will be expanded in the fall, we have solved this problem now. The bot listens to 2 or more group chats and forwards all messages from one to the other.

Of the complex and useful projects on this framework, which we have done - the brodcasting bot. Firstly, it allows you to bypass the restriction on 100 people in mailings, secondly, it allows you to create different groups of users for mailings through a convenient interface, and thirdly, it allows you to find all the important information for a person in one chat with the bot. This service can be used for information inside the university, city or any organization.


Boat "Fellow"
The developer will be the best to tell about the project - Ilya Shimchik :

The idea was born from the need to get less spam in the Telegram chat. There is a group chat where people find a companion and leave requests to the driver. And this is not the most convenient solution, because from time to time the search for fellow travelers falls into a terrible flame. Therefore, the idea to simplify the process of finding companions and, at the same time, to reduce the number of spam.

The procedure for creating a bot is not complicated: the steps to create it are simple and have already been described more than once; the most correct way is to start from the official site: core.telegram.org/bots .

The Telegram API has two ways to interact with the backend of the bot: through the webhook and through polling. I chose the first option, as it is faster and easier. Then everything is simple: we write backend, we form a list of bot commands, we make handlers for messages, we create an interface and voila - everything works.

It is worth paying attention that webhooks works only under the https protocol and the self-signed certificate does not fit, the Telegram API will not allow the webhook address to be hung with the self-signed certificate. For this there is a temporary solution - use ngrok (link) to test your bot directly from a local computer.

image

As a result, the first version of the bot is now working. Already accumulated a list of the nearest features that will be added to the bot, such as notification of the appearance of the trip, taking into account the remaining empty seats in the car, adding a comment field to the trip.

I want to develop this idea to a full-fledged service to find companions not only in Innopolis, but also in Kazan. I also plan to teach the bot to understand free speech so that the trip can be created, for example, with the following sentence: “I am going to go to my grandmother after a week, there is a place for 3 fellow travelers, not to smoke in the car!”


In conclusion, perhaps, it is worth saying a couple of words of praise to Telegram: a fast and secure IM service that is easily picked up by the audience and, through bots, provides affordable tools for the appearance of essential services for this audience. Firstly, it allows evolutionary development of the audience and its needs in a clear direction, based on the confirming hypotheses of the value of the service. Secondly, the process of developing services does not require a huge number of man-hours.

By implementing bots, this already good service created an excellent support for transforming oneself from the IM protocol into a flexible platform for services. Moreover, the bots buttons inside applications allow you to easily make a simple interactive interface for anything.

Bravo and Respect, Pavel! I think the developers in Innopolis, and just the residents of the city, it would be interesting to talk with the creator of Telegram and get to know his vision of a future messenger.

image

PS As for Innopolis, it is possible that it will become the first city using the Telegram platform as a unified authorization system for residents for all digital services of the city. Moreover, on habr'e there were already posts about the possibility of user authorization via Telegram habrahabr.ru/post/264301 (the most interesting thing about deep linking in the comments).

PPS If you are interested in participating in the creation of these or other services - always in touch in Telegram: telegram.me/ior_um

Source: https://habr.com/ru/post/267723/


All Articles