How Donna met LUIS
Meetings, meetings, meetings …
Ever wondered how you are supposed to schedule that meeting? Too busy, too little space in your agenda and too many things on your mind? From now on, Donnabot can take some work out of your hands, by offering the services of a personal assistant that takes care of meetings, before, during and after. We developed Donnabot for the Hack Days, a hackathon organised by GSK.
Donnabot, what’s in a name? Well, a little fun fact, the name originates from the series “Suits”, in which Donna is the personal assistant of top-lawyer Harvey Specter, and she knows literally EVERYTHING. We developed a chatbot that can handle every meeting in your agenda. Before a meeting starts, she can schedule meetings, reschedule and cancel them. But more than that, she can also send reminders, to let you know that time is running out and that you better hurry up, because the meeting is starting. During the meeting she can write down your todo list and notify when there’s not much time left and you should try to finish the meeting. After the meeting, you can request your todo’s and start working on them. For the hackathon we developed Donnabot for MS Outlook but alternatives are an option, as long as they have an API.
I just described the functionality of the Donnabot, but to be honest, it’s only a description of what we did for the GSK hackathon 2018. You can extend it as much as you want (more or less). Want it to classify your emails? Let it do so! Have another idea, shoot!
So who’s Luis and how did he meet Donna?
In the next sections, I will discuss the code behind the bot in more detail. But I’m not going to discuss it all, since that won’t fit in a blogpost. Therefore, I will focus on the core functionality, and this way we will find out how Donna met Luis (read: the Microsoft LUIS).
So imagine you start a conversation with Donnabot, then most likely you will say hi and ask her how she’s doing. And that’s where LUIS meets Donna. LUIS is a natural language processing service, developed by Microsoft, that can recognise what you said in “natural language”. This is basically the language as it is spoken or written. LUIS recognises “entities“ in the text and couples them to an “intent”. According to Microsoft:
“Entities are important words in utterances (read: sentences) that describe information relevant to the intent, and sometimes they are essential to it.”
“An intent represents a task or action the user wants to perform.”
For the example of saying “hi” to the bot, LUIS will recognise it as a “greeting” (intent) and couple an action to it, which is replying with for instance “hello”.
The figure below shows the web interface of LUIS, in this case for another intent, named “TodoWrite” to which an action in Donnabot is coupled to write down todo’s in MS Planner. As you can see, there are words in blue. When you’re in the actual web interface, you can hover over them and then you see what’s inside the entity. So let’s take the first sentence (also called “utterance”), “write a to do for the PlanName project: TodoName”. Here, PlanName and TodoName are entities and inside them are the words “business” and “read financial plan“.
LUIS web interface for the intent “todoWrite”
Now, if you enter a sentence in Donnabot, she will immediately send it to LUIS. LUIS then recognises the entities and based on this and the context of the sentence, LUIS knows what’s the intent. The action that will be performed matches both the entities and the intent. Let me give an example: suppose there is one todo list in which all the tasks have to be put. Then LUIS should know what’s the task name, right? This is typically one of the entities in the sentence. But based on just the taskname, LUIS doesn’t yet know whether it should delete or write the task. And that’s where the other entities and the intent comes in. Because based on all entities, LUIS can know what intent (delete or write a task) it is, and only then it can put a task with the right taskname into the tasklist (or delete it).
Entering sentences into LUIS via the web interface can be a pain, especially if you need to enter many sentences and their variations. I once entered more than 3000 sentences manually and I made up my mind to never do this again, because it takes SO MUCH time. So for one of our other applications, a collegue of mine automated this process. Now we can enter sentences in an excel file that is converted into a .json file that we can subsequently import into LUIS. Which goes faster and most likely contains less mistakes (yes, you can get quite dull after entering let’s say 500 sentences!). When the sentences are entered in LUIS you only have to decide about what the entities will be. My tip for using entities quickly is to use lists whenever possible. Because list entities are recognised automatically in a sentence and simple entities are not, in which case there will be a lot of manual work left.
What LUIS makes Donna do
Since recently, you can use LUIS action bindings, to bind actions to LUIS intents. But before you really bind the action to the intent, it’s a good idea to check whether we have all the requirements that we need in order to do this. For example, suppose you want to book a meeting room, but you don’t know how many people will attend the meeting, nor around which date the meeting is supposed to be. Then, booking a meeting becomes quite tricky, right? Therefore, we check the requirements. The code below shows how we do this. As you can see, as soon as LUIS detects the intent “MeetingRoom”, then the code checks whether the entity “peopleNr” is present in the sentence or not, as well as the entity “Date”. The code then returns a result that contains the number of attendees and the date.
This result can then be used in a dialog. In our case we have one main dialog that handles the actions related to the intents returned by LUIS. And in order not to make the main dialog too extensive (to avoid a file with 10,000 lines of code), we put some code into “Helpers”, which are basically files with a part of the code that you need to perform an action coupled to the intent. You can then call these “Helpers” from your main dialog to complete an action. One method in the main dialog is called MeetingRoom and describes the action that should be performed in order to book a meeting room. By adding “LuisIntent(“Meetingroom”)”, you can bind the action to this intent.
In case you are interested in using action bindings yourself, then you can find the source code of the LUIS action bindings here. The trick is to include it in your .vs solution as a project.
Did Donna and Luis live happily ever after?
Find it out for yourself!
New to building chatbots and don’t know where to start? Check out this blog!
This blog was originally posted here.