Virtual Djinn on March 8 - or how to surprise your employees on a spring day

  • Tutorial


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

Here we are in Just AI thought, thought and thought up! Under the cutscene - a ready-made tutorial that you can also launch 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, he will probably also think about flowers, compliments ... And so all day.

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



"Interesting" - we thought. But what if you create a chatbot in Telegram that will offer a wish menu to every beautiful employee of our office? She chooses a desire, and it flies away for execution to one of her colleagues. “Yes, it's like a magical genie from Aladdin’s lamp!” - the girl simply clicks on the wish menu from the list, it flies away to one of the male performers, and after a couple of minutes a good fellow arrives at her with what she wished! Well, it started ...

Next, I will show how we launched such a bot in an hour on our constructorAimylogic . 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 sparkle with new colors! Tested on us.

Template


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



Next, click on the Publish button in the upper right corner and select the Telegram channel . You will be asked to indicate the bot token in 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.

Next, I’ll talk about how everything works, and what can be changed in the project to make it unique.

How does it work


The bot starts its work with a welcome screen (the leftmost in the project). And then he immediately jumps to the menu with buttons - this is the same wish menu. Each button corresponds to some desire that we (men) agree to fulfill (because everything has a measure).

Of course, a sweet lady can not only click on a button, but also write a wish on the keyboard. In order for the bot to understand what desire this text message corresponds to, in Aimylogic there is 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 own items to the menu, but do not forget to change the list of buttons in the script.

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

Count the time


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



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. At the next step, the bot simply checks the condition and either sends a request to the contractor, or asks its interlocutor to wait a bit.

How the bot selects the executor of desire


Everything here works like this. We create a regular Excell plate on Google Drive, where we register all the men participating in the action (what if someone refuses). An example of such a tablet 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 starting a special bot (which will notify of incoming applications), and the name of the artist - the lady who sent the application 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 it in the URL of the form tools.aimylogic.com/api/googlesheet2json?id=1RFE5hIi7R9QYWC0OzDczL1UZKggcufbINuOLQUKgbl0- it will turn your table into a JSON array with fields corresponding to the column names. This is what we substitute in the HTTP request in our script in Aimylogic, so that the bot selects one of the participants to fulfill the desire.

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

Where the application is sent


Excellent! Our bot accepts the desire, selects the artist from the list on the Google plate, and then he must somehow notify this artist that it would be time for him to bring a cup of coffee, organize a light snack or come up with an unheard-of compliment. But how do we do this?

We decided to do just that. Published another simple bot in Telegram t.me/GenieCenterBot(by the way, you can also use it, so as not to create your own separately). It works on the principle of “Uber for taxi drivers” - that is, it is intended only for performers of desires and simply notifies you of a new application by the performer. At startup, it issues an identifier, which you need to write in Google a table with a list of performers. Actually every man who participates, puts himself this bot and reports the identifier to the one who manages the table.

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 bot-executor of desires. 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 Aladdin’s lamp. And his phrases are appropriate. You can have it someone else - Old Man Hottabych, Golden Fish or Two from the casket :-) The main thing is to replace the pictures and replicas.

Another wish list


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

Custom desires


We also made it so that our girls could order wishes that are not on the list. True, we don’t run to execute them right away (you never know what they will do there ). We first send the wish text to the Trello special board through the same IFTTT service , vote there with our team in a closed chat room, and then, if the desire passes our “moderation”, we add it to the bot.

Statistics


The funny thing is to keep track of how many and to whom desires have fallen, who is the most active participant in the March flash mob and so on. To do this, again - just send each desire to some kind of plate on Google drive via IFTTT.

Chat with Genie


And if something breaks during the day? Or does one of the performers take too long to complete an application? This must be closely monitored! And for this, you can connect an online chat with an operator to the script (for example, LiveTex or Webim). As soon as the girl clicks on the Chat button with Genie , control will go to a living 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, March 7 is in full swing! So, it's time to surprise!


Also popular now: