In a previous blog post, we talked about our experience at the 2017 Hackatrips Hackathon at Fitur. In this post, we go more in depth into the technologies we used, and how we put it all together, with a special emphasis on Natural Language Processing (NLP) with LUIS.
Getting started with the Bot Framework was quite simple, thanks to the Node.js SDK. Another very cool thing about Microsoft Bot Framework is the Bot Framework Emulator. This cool little piece of software allows you to test your bot very easily on localhost. While it is missing some interesting features such as having more than one conversation at a time, it did wonders for developing the bot quickly and efficiently, which was key at the hackathon.
The dialog tree for our app was very straightforward. After the initial greeting, the user can ask for a cab. The app asks questions until all necessary info (pickup time and destination) is gathered, and then sends a quote with the price of the ride. If during the waiting period another user in the vicinity is going to a nearby destination, both users are notified that they will share a ride, and the new, cheaper price is displayed.
Now, of course there are infinitely many ways to ask for a cab, and infinitely many ways to ask for a time and destination. We need our bot to understand what it is being told. To tackle this problem, we used LUIS, Microsoft’s natural language classifier. A natural language classifier is a machine learning tool that can take a sample sentence and classify it according to its intent, and recognize entities within these intents.
The concept of intent and entity is crucial for this exercise. Intent is defined by the will of the user, it is what they want to get from an action. Entities are the relevant keys that can be identified from an intent. For example, our app had only two intents, to greet or to order a cab. Within the ‘asking for a cab’ intent, there were two entities, pickup time, and destination. The way we designed this bot is a so-called ‘slot-filling’ model. Essentially the user invokes the intent, and the bot keeps asking questions until all the slots are filled, and all the info is acquired. In our case, we had three scenarios:
The user just asks for a cab: In this case we are missing the location and pickup time slot, so the bot asks first for one, and then the other, and then it’s ready to go.
The user gives of the intents: User says they want to go to Hotel Marigold. We know they want a cab, we know where they want to go, we are just missing the time, so the bot asks for it. Vice versa if the user gives just a pickup time. The bot has to understand what entity has been gathered, and ask for the other one.
The user says everything in one sentence: In this case, it is important that the model is well trained to perfectly separate the time and destination entities.
LUIS was a great fit for our bot because it is relatively simple to use, quick to train, integrates seamlessly to the bot framework, and -let’s face it – we really wanted that Xbox One. Once our intents and entities were defined, we had to train the natural language model. We fed the model with a few dozens of different ways to ask for a cab, with all possible combinations of slot-filling. After a few, the model could recognize the entities by itself, needing only validation from the human.
In addition to building the guts of the bot, we had to work with the Cabify API. We devised a system of ordering and canceling rides in order to be able to share cabs, and then integrated in into the conversation, giving the user the price and definitive pickup time. User requests were stored, so when a second user ordered a cab from a nearby location, both users could be unified in a single cab request. We also used the Google Places API to geocode the destination request and get a latitude and longitude for the API to set as the destination for the taxi. Once the entire Cabify logic was finished, it was incorporated it into the conversation.
The end result was something like this:
Our initial objective was to deploy the app to Azure, and then connect the bot to Facebook Messenger through a Facebook app we had created for this purpose. We did run into a bit of trouble in this aspect, and time was certainly a constraint, so we settled with demoing the project on the emulator.
http://tech.geoblink.com/wp-content/uploads/2016/10/GeoblinkTech.png00mfajardohttp://tech.geoblink.com/wp-content/uploads/2016/10/GeoblinkTech.pngmfajardo2017-02-17 10:59:122017-04-23 10:45:15MICROSOFT BOT FRAMEWORK AND OUR FRIEND LUIS