Bot Dev: How to configure chatbot in Telegram

In previous articles (part 1, part2) we created chatbot for Telegram. As I promised, here we will configure some settings of our bot: commands list profile photo about text bot description Let’s begin by configuring our commands list. Commands list Command list represents the commands supported by the bot. Telegram suggests them when user types / in the chat with our bot. Each command in this list has a name, which starts with ‘/’, and a text description. Command name length is limited to 32 characters. ...

February 6, 2017 · 3 min

Sling Models: How to write Sling Model Injector

Once I needed to write several debugging servlets for some functionality. Those servlets had to accept a big pile of parameters and I was tired of having tens of rows like String paramValue = request.getParameter(“paramName”). Luckily, I’ve already known Sling Models. So I’ve decided to find the way to inject these parameters into the model, so I could write just request.adaptTo(MyModel.class) . Unfortunately, I found nothing, so decided to write it myself. So in this article, I will show you how to write custom Sling Model injector on the example of Sling Model Request Parameter Injector. ...

January 25, 2017 · 7 min

Bot Dev: Write a stateful Telegram bot – Part 2

In the first article, we implemented pretty simple Telegram bot, which gathers user requests to fix something. It’s already can be used in our business while we want to post-process requests with a separate tool. But, maybe, it would be too easy for us, so we will go ahead. Application Requirements In this article we will add next features to our bot: initial authentication of our repairers requests broadcasting to our repairers request assignment to the repairer Telegram Bot Deeplinking Let’s imagine that we have some separate administrative tool for our bot. And there we defined several unique IDs and assigned them to our employees/friends ( friends-employees? Why not). And now we need to authenticate them in our bot, so we can send them fix requests from our customers. We can use deep linking from Telegram to solve this task. ...

January 9, 2017 · 12 min

Sling Models: Why do I like @Self annotation?

At some point, Hexagonal architecture has been introduced to me. It espouses a one-way flow of dependencies - from the outside, in. And this is a great way to increase maintainability. However, we still need to access request and other external resources in our Sling Models. That is where @Self annotation can be used. @Self Annotation According to the documentation, this annotation injects the adaptable object itself. If the @Self annotation is present it is tried to adapt the adaptable to the field type. ...

January 5, 2017 · 3 min

Bot Dev: Write a stateful Telegram bot - Part 1

Why do we need all these bots? Why people are talking about them so much? What the bot is good for? Look around, it’s 2017 outside and nobody uses phones for calls only. Even more: today a lot of people prefer chatting to calling somebody. But, you are still forced to make calls to get a taxi or to understand why your LAN connection is down (oh man, you again forgot to pay for it!). How often are you listening to the music, when you are on hold, instead of doing real business? That’s fine when it’s Bach, but what if it’s Justin Bieber instead? They are just wasting your time! Chat is a better medium for a lot of people. But, yeah, you still will wait until there is a free person to respond you. Ok, finally somebody responded to you, but what if that person is in bad mood? So it still looks too unreliable and complicated. That is where bots come into play. ...

January 2, 2017 · 14 min