In my last two posts, I wrote about Microsoft Azure Bot Service, briefly explained how it works, and went over the configuration of a Question and Answer (QnA) chatbot. Today, I will continue this topic and present how to configure a language understanding bot hosted on the Microsoft Azure cloud platform.
A language understanding bot uses natural language models to understand user intent in communication. Intents are how Language Understanding Intelligent Service (LUIS) determines what the user wants to do. For instance, if your client application is for IT support, then you will need intents such as “GetComputer” and “OrderLicense” in order to identify when your users want to perform these different tasks.
A language understanding bot is more advanced than a simple QnA chatbot. The key role here is assigned to Language Understanding Intelligent Service (LUIS). It is one of the cognitive services from Microsoft Azure that enables applications to understand what the user is saying in natural language. It can take the text provided by the user and break it down into components pointing out to intents, entities and other elements.
Here are some key terms associated with the LUIS service.
An intent represents the action the user wants to perform. The intent is a purpose or goal expressed in a user’s input, such as booking a flight or paying a bill. You have to define and name intents that correspond to these actions. A support app may define an intent named “GetComputer.”
An utterance is text input from the user that your application needs to understand. It may be a sentence, like “Where can I get my computer?”, or a fragment of a sentence, like “Computer” or “Computer order”.
An entity represents detailed information that is relevant in the utterance. For instance, in the utterance “Order new computer on 25 of January”, “25 of January” is the key date. Entities which are mentioned in the user’s utterance can help LUIS choose a specific action to take in order to respond to the user’s request.
Below are some examples of intents, utterances and entities:
In this post I would like to present how to set up a Support Team chatbot which uses LUIS to understand the users’ questions.
A simple language understanding bot does not require writing a single line of code. Everything can be configured in the LUIS portal. It is very important to specify the region where your LUIS app is published. You can check the available regions in the Regions and keys section.
1. Click the Login/Sign up button and sign in with your Microsoft Account (if you do not have one yet, you’ll need to create it first).
2. From the top panel, select My apps and then click the Create new app button.
3. Type the name – SupportAssistant in our case – select English as culture and then click Done.
4. Click the Create new intent button.
This is the place where intents can be defined, so the chatbot can understand what the user is saying in natural language.
5. Type RepairComputer as Intent name and click the Done button.
6. Here we need to add some sample utterances which the user might say. I prepared five sample utterances below:
7. Now entities used in the intent should be added to help LUIS choose the specific action to take to answer a user’s request. Entities are optional, but they are helpful. I chose three sample entities listed below:
To add an entity, move the mouse cursor over the word in one of our five utterances, for instance move it over the word computer. A dialog box should appear. Click Create new entity.
Type computer as the name of entity, select Simple as entity type and click the Done button.
At this point it may be helfpul to describe the entity types.
A simple entity is a generic entity that describes a single concept like computer or order.
A hierarchical entity is a special type of a simple entity; defining a category and its members in the form of a parent-child relationship. For instance, there can be a parent Location entity with FromLocation and ToLocation child entities.
A composite entity is made up of other entities, such as prebuilt entities, list entities, and simple. The separate entities form a whole entity. PlaneTicketOrder is an example of such an entity, because it can have Number and ToLocation child entities.
List entities represent a fixed, closed set (white list) of related words in your system. City list is a good example because it allows variations of city names, including city of airport (Sea-tac), airport code (SEA), postal zip code (98101), and phone area code (206).
A regular expression (regex) entity ignores case and ignores cultural variants. For instance regex entity kb[0-9]{6,} matches kb123456.
You can add report and broken entities in the same way as the computer one.
8. Click the Train button at the top. It should display a green bar with successful training.
9. Click the Test button to run some tests on your prepared LUIS application.
10. Type an example utterance, sych as “My computer is down. What can I do with it?” and click enter.
11. To view the result, click the Inspect label.
Please note that based on this provided utterance, LUIS returned a top scoring intent called RepairComputer. Even though the utterance was not exactly the same as the sample utterances provided earlier, LUIS was able to identify it.
Once your Language Understanding Intelligence Service application is cofigured, you should publish it, so that your bot can connect to it.
1. From the top panel, select PUBLISH.
2. Click the Publish to production slot button.
Once you’ve published your LUIS application, it is time to set up the bot and connect it to LUIS. The below diagram presents the language understanding bot solution architecture.
We will use the Microsoft Azure Bot Service to set up the chatbot and to connect it to the LUIS application. An active Microsoft Azure subscription is required.
1. In Microsoft Azure portal choose Create a resource.
2. Type Bot in the search window, then select Web App Bot and click the Create button.
3. Next, a blade with configuration should appear.
There are a few details which you will need to provide in order to configure your chatbot within Azure Bot Service:
Once your configuration is ready, click the Create button. After a few seconds, language understanding bot service is enabled.
Click IntelligentSupportBot Web App Bot to open the blade with details.
To correctly integrate LUIS bot with Azure Bot Service, you should provide three values in Application Settings:
You can find these values in LUIS portal in the PUBLISH tab. Copy them to a safe place.
Now in Azure portal, open the Application Settings tab and paste the values as shown below, then click Save.
Once you’ve configured everything, you can test your chatbot. It is possible to do it via a Web Chat window.
I typed a question related to a broken computer and sent it to the bot. Then LUIS analyzed my question and assigned a suitable intent to it, which in this case is RepairComputer that I declared earlier in the LUIS portal.
There can of course be more complex use cases for specific requirements. In this particular case, the bot could ask the user about more details related to the broken computer to provide some advice.
Earlier I described Microsoft Azure Bot Service including chatbot templates and Question and Answers (QnA) bot configuration to show how it can improve communication and interact naturally with users. In this article, I presented how to connect the bot to Language Understanding Intelligent Service (LUIS) which uses natural language models to understand user intent in communication. Language understanding chatbot can be available for users through different channels too, such as Skype, Slack or Facebook Messenger.
This type of bot can be really useful in a variety of scenarios, not just IT support. You can use it to help make various arrangements (such as booking a flight) orto generally improve customer service in situations where your users may not be familiar with all available options and need something to guide them.
Contact us so we can help implement your idea on how to use chatbots.
Read other similar articles