⬆️ ⬇️

Virtual Djinn on March 8 - or how to surprise your female employees on the very spring day





Tomorrow throughout the world we will celebrate the most feminine day of the year. And it is beautiful! But this means that today is the day when we congratulate our dear female employees . And every year we (the male part of the labor collective) think how to do it in a special way ... Flowers, an evening banquet - all these pretty platitudes are pleasant, but in the 21st century, everyone wants something technologically and modern.



Here we are in Just AI, thought, thought and still come up with! Under the cut - already ready tutorial, which you can also run right now and turn the usual March 8 into a sea of ​​positive!



What did we come up with



How would you answer the question “What is the best gift for March 8?” If the reader is a man, then he will probably also think about flowers, compliments ... And so it’s all day.

')

And here we came across one interesting menu ... Here it is







“Interesting,” we thought. But what if you create such a chat bot in Telegram, which will offer a menu of wishes to every beautiful employee of our office? She chooses a wish, and it flies away to the performance of one of her colleagues. “Yes, it's like a magical Djinn from Aladdin’s lamp!” - the girl simply clicks the desires menu from the list, it flies away to one of the male performers, and after a couple of minutes, a kind fellow arrives at her with what they wished! Well, it started ...



Next, I will show you how we launched such a bot on our constructor Aimylogic in an hour . You can create it even faster - just by clicking on the already prepared template, which we also prepared, change it a little if you wish - and your office celebration on March 8 will play with new colors! Checked on us.



Template



As I said above, you can simply log in to your Aimylogic account and click on the “March Jinn” template to instantly create a finished bot.







Then click on the Publish button in the upper right corner and select the Telegram channel. You will be asked to specify a bot token in the Telegram. To get it, open the Telegram client, search for the @BotFather bot and create a new bot there. Read more about creating a bot here .



After you publish your project in the Telegram channel, it will start working in your bot.



Then I will talk about how everything is arranged, and what can be changed in the project to make it unique.



How things work



The bot starts its work from the welcome screen (the leftmost one in the project). And then immediately jumps to the menu with buttons - this is the very menu of desires. Each button corresponds to some desire that we (the men) agree to fulfill (after all, everything is a measure).



Of course, the lovely lady can not only click on the button, but also write the desire on the keyboard. In order for the bot to understand what desire this text message corresponds to, Aimylogic has a tool called Entities . If you look there, you will see that this is a wish list with different formulations of each of them. Actually here you can add your items in the menu, but do not forget to change the list of buttons in the script.



When a girl presses a button or writes some kind of desire, similar in sound to what is in essence, the $ desire variable is filled in - it will store what is in essence indicated as Essence. This is what will fly to the performer along with the contact information of the fair sex.



Count time



Of course, if all the ladies click on all the buttons in a row, this can provoke an overload of the performance system (that is, us, men). Therefore, we propose to limit the time between two desires in a row. For example, 10 minutes. Or 20. You can change this. On the screen, which is signed as We count the time , you can see how the bot calculates the time between two wishes.







Actually here the bot receives the current time from our service, then creates a couple of variables in which it saves the time elapsed from the previous request. In the next step, the bot simply checks the condition and either sends the application to the performer, or asks its interlocutor to wait a little.



How the bot chooses the performer of desire



It all works like this. We create a usual Excell tablet on Google Drive, where we register all the men participating in the action (and suddenly someone will refuse). An example of such a label is docs.google.com/spreadsheets/d/1RFE5hIi7R9QYWC0OzDczL1UZKggcufbINuOLQUKgbl0/edit?usp=sharing



As you can see, it has two columns. The identifier is a unique number that each participant receives when launching a special bot (which will notify about applications received), and the name of the performer - the lady who sent the request will see it.



Next, you need to publish it on the web (File - Publish on the Web), copy the identifier from the address bar and substitute in the URL of the form tools.aimylogic.com/api/googlesheet2json?id=1RFE5hIi7R9QYWC0OzDczL1UZKggcufbINuOLQUKgbl0 - it will turn the message to create an invoking message, you can create a message, you can create a request for a service provider, etc. column names. This is what we substitute into the HTTP request in our script in Aimylogic, so that the bot chooses one of the participants to fulfill the desire.



In the $ genie variable, we will write down a randomly selected artist like this
_.sample($httpResponse) 
(since Aimylogic supports underscore )



Where the application is sent



Fine! Our bot accepts a wish, chooses an artist from the list in a Google plate, and then must somehow notify this artist that it is time for him to bring a cup of coffee, arrange a light snack or come up with an unheard of compliment. But how do we do this?



We decided to do simple. They published one more unpretentious bot in Telegram t.me/GenieCenterBot (by the way, you can also use it not to create your own separately). It works on the principle of "Uber for taxi drivers" - that is, it is intended only for the performers of desires and simply notifies you that a new application has been received. At startup, it issues an identifier, which you need to write to Google table with a list of performers. Actually, every man who participates sets himself this bot and gives an identifier to the person who manages the table.



A bot for girls after selecting an artist makes an HTTP request to the Telegram API to send an alert.



What else can I add?



So, we have a template with a desires bot. And you are free to change it as you like. What can be done to make it more interesting?



Another character



We have this genie from the lamp of Aladdin. And he has the appropriate phrase. You can have someone else - Old Man Hottabych, Goldfish or Two of the casket :-) The main thing is to replace pictures and replicas.



Another wish list



As I wrote above, you can change your desires as you please. To do this, you need to change the list of entities and buttons on the screen with a menu. It all depends on what you, the performers, are ready for the beautiful ladies ...



Custom wishes



We also made it so that our girls could order desires that are not on the list. True, we do not run to execute them immediately (you never know what they want to do there). We first send the desire text to the special Trello board through the same IFTTT service , we vote there with our team in a private chatik, and then, if the wish passes our “moderation”, we add it to the bot.



Statistics



The funny thing is to keep track of how many desires fell out and who desires, who is the most active participant in the March flashmob and so on. To do this, again - just send each wish to some kind of tablet on google drive through IFTTT.



Chat with Jinn



And if something breaks during the day? Or someone from the performers too long to execute the application? You need to follow this closely! And for this, an online chat with an operator (for example LiveTex or Webim) can be connected to the script. As soon as the girl clicks on the Chat with Jinn button, management will go to a live person who will help solve any problem.



The holiday comes to us



If you have read to the end, then you are ready to launch this miracle bot in your office? Hurry up, March 7 is in full swing! So, it's time to surprise!



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



All Articles