In addition to client projects, we really love to create internal projects - for fun and convenience. It's cool when you and your colleagues can come up with a super-application or a bot for stand-ups . An internal bot has also appeared for opening doors and viewing cameras, which I will talk about in this post.
Disclaimer : If you are looking for complex technical cases, I'm afraid I have nothing to please you. I am telling you in advance so that you do not have false expectations. We've got a simple yet effective solution that can be easily done in a couple of hours and get tons of value.
How the bot works
The bot is extremely simple: two buttons for doors (open a door, open a gate) + several buttons for cameras.
At the same time, at the launch, the effect turned out to be insane - they immediately began to use the bot, and just like that, because it's cool to change something around with one tap on the button.
The bot saves time
A bot is convenient. Especially when you forgot your keys or when you are too lazy to get them while you go to smoke. It seems that these are trifles - well, you get a bunch of keys with a keychain from Paris or a pass from your pocket and put it to the door. But our whole life consists of such little things - it seems that if you save 10-15 seconds every day, you can enjoy reality for an additional 5-10 days. Check out this beautiful infographic of where our years of life go.
But the main reason for the bot is couriers. We have a two-storey office of 800m², but with one entrance for couriers. If you work on the ground floor, then there are no problems, but it will take forever to get from the DevOps department to the entrance.
Meeting with the courier after many years of wandering
At the same time, the meeting of the courier in itself does not make sense: you see a guy in overalls, open the door for him with a button, wait for him to come, open the cherished chest, take the package and open the door again with the button. And then - the long way back.
Everything would be easier with a bot. You work calmly, the courier calls, you ask him to press the bell button and leave the order at the door, you hear the bell. He pressed the button - opened the gate, pressed the second - opened the door. Courier left food - Profit!
The main thing is to press two buttons - doors and gates. Otherwise, the courier will get stuck in the courtyard and swear in an incomprehensible language, like the character "The Sims", in horror not knowing what to do.
How the bot monitors the office
With the door sorted out, but then another problem arises - outsiders can knock on the office. If everything is clear with the guys in overalls, then if a client, partner or someone unfamiliar has arrived, everything is not so simple. For such cases, the integration with cameras came in handy. It is convenient when you can tap one button and understand who is there behind the door.
There are several cameras and if you click on each one, you can check if everything is in order in the office, if you forgot to turn off the light and if you left your things. It is clear that if you forget your phone in the toilet, then no bot will help. But if in a fitness corner, then quite.
What's inside the bot
We have written a special service, as it is dangerous to do without it - I would not want someone to accidentally stumble upon a bot in search of a bot and could open the doors in our office. Such a person sits in Pereslavl-Zalessky and brings confusion in the Moscow mobile production.
And this is Pereslavl-Zallesky. Looks great!
Therefore, we made a mechanism for confirming and banning the user - a person enters a phone number for registration, and the admin bot confirms it with a command.
We don't even think about hacking. The bot is running on the internal network, so there is no need for any additional protection. There is no external way to access an application that executes commands, except through a bot. The only way for a stranger to open the door is to find one of our employees on the street, grab the phone and open the door. In fact, we entrusted everything to Telegram.
Bot and cameras
The story is similar with cameras. There is an internal network that automatically generates previews. All that is required is to refer to the link, which is always guaranteed to have a fresh picture - the last frame from the camera. It is always stored in the "RAM" - it is not constantly updated, but it certainly is. It is precisely in the "operative" that the calls are made according to the clever authorization scheme.
By "tricky" I mean a non-standard request, which is hardly used anywhere other than cameras. You need to specify the username and password directly in the domain, just like mailto. Then everything is simple - Java accesses the URL, saves the file and uploads it to Telegram. The bot does not create a new frame, but overwrites the existing one. He is not interested in who came to work, he is only interested in the current state. Each image weighs about 200-300 KB, there is no talk of high loads. But so that no one could "put" the bot, and so that the bot would not be banned by Telegram for spam, we added a 10-second interval between sending requests.
The only thing we do not know is how images are stored - there is an idea that sharding solutions are used to move files that have been used for a long time to separate servers. If you know how it works, let us know in the comments.
The last thing worth noting is the nightly notifications. We occasionally throw office parties, plus we always have people who leave the office later than others. Therefore, we made it so that if someone uses the bot from 00:00 to 09:00, then the user and specially marked people receive a notification.
Anyone who used the bot receives a notification with a request to turn off the lights, air conditioners and close the windows. To specially marked people - the usual notification that such a user has used the bot, this is necessary to understand that everything is ok and there are no strangers in the office.
As a result, it turns out that we have a database with the following roles:
- admin who confirms and bans;
- user who uses;
- alert that receives notifications.
Previously, things were not going very well with speed in general - thanks to the blocking of Telegram. Commands that were supposed to take 2-3 milliseconds took a second to complete. And for all links that use proxies (receiving and sending), the ping increases many times.
Sometimes this led to crashes and crashes. People got used to poking the "open" button 50 times. And then, with a delay, you could hear the symphony of doorbells. We had to change ports and proxies, while we did not hardcode, so that we could safely change one digit voila.
Bonus track: coming up with ideas of what else you can come up with for the office. Come up with you too
- . , «FINCH ». , , (, ).
- : , , « ?» «» «». , .
- CO2. , . «», , .
- . , . , . , . , — — .
— ? , , , . , , ?
In fact, there are no cases that cannot be technically implemented in a bot. It always comes down to UX, ergonomics and imagination. Telegram allows you to make any inline keyboard with buttons of any size, even a 50 by 50 matrix. But these buttons are all there is: no tapes, screens, burgers, checkboxes.
At the same time, making individual bots is even worse, because you have to look for them, and this is so many clicks that why such a bot at all, if it's faster to do everything manually (even if you are sitting in the DevOps department and you need to meet a courier).
However, no one forbids dreaming. Tell us about the craziest ideas for the Telegam bot, and we will distribute exclusive FINCH T-shirts to the authors of the coolest ones. We will ship anywhere in the world
Thank you!