Chat Bot Using Microsoft Bot Framework With LUIS - Part One

In this article, we are going to see how to configure LUIS apps.

What is LUIS?

LUIS - Language Understanding Intelligent Service.

We can teach this service to understand intention and extract the entities from user query/activity. Client app (e.g. chat bot) can consume this output using HTTP endpoint of LUIS application, and will work on intended functionality.  If a user has queried “Please show leave balance of Akshay”, then an educated LUIS app will extract intent as ‘to get leave balance’ and ‘Akshay’ as entity. This will convey feelings to the end user as client application is able to understand queries asked in a natural language.
  • To start with LUIS, go to luis.ai
  • Click on sign in and log in with your Microsoft account. You can see 'My Apps' tab defaultly selected. ’My Apps' tab will list down all the LUIS apps you have created earlier.

    Microsoft bot framework

To create a new LUIS app, click on 'New App' button. It will pop up the following page.

Microsoft bot framework

Here, you can specify Name, Culture, and Description for your LUIS app.

The most important attribute is Key to use. Here, you need to specify Endpoint key. It is required while publishing the app and accessing its HTTPS endpoint. By default, free key (named Bootstrap) is provided by Microsoft with a limit of 1000 hits per month. You can select this key and click on "Create" button.

  • You will be redirected to applications page again and will see your application listed there.

    Microsoft bot framework

Click on application and it will redirect to Dashboard. Here, it shows id of app, counts of intents, and entities. If you want to know about dashboard in details, click on the Learn more link.

Microsoft bot framework

On dashboard, it is highlighted as our app has no intents and entities yet. But before creating, let us understand about them first.

Let us take an example such as ‘A person wants to know an address’. There are multiple ways to ask for an address, some of them are listed as

  • Where is the Eiffel tower?
  • May I know the address of Jack?
  • Where do you live?

When anyone asks us the above questions, our brain understands that the intention of the person is to know the location. But the answer for each question will be different because of the entities involved in the query.

  • Utterance is a ‘query/input from the user’.
  • Intent is an ‘actions the user wants to perform’.
  • Entities are ‘objects referred to in query’.

To understand it clearly please refer to the table below.

Query - (Utterance)Intention - (Intent)Entities
Where is the Eiffel tower?To know addressEiffel tower
May I know the address of Jack?To know addressJack
Where do you live?To know addressYou
What is your name?To know nameYou
What is the rank of Akshay on C Sharp corner?To know the rankAkshay, C Sharp Corner

Now we will start by adding intents to our app. Click on ‘Intents’ in left hand side bar menu.

Microsoft bot framework

Click ‘Add Intent’. Provide name and click ‘Save’. I want to add greeting and a welcome intent.

Microsoft bot framework

It will redirect you to the  intent page to add utterances. I have added the following utterances for ‘Greet.Welcome’ intent.

Microsoft bot framework

I have also added ‘Greet.Farewell’ intent with following utterances.

Microsoft bot framework

Now I want to add intent for searching people. I will add intent with name ‘Search.People’.
Microsoft bot framework
I will add first utterance as ‘find Akshay’ and press enter. It will get added in list.

Microsoft bot framework

I want to highlight ’Akshay’ as object in utterance i.e. instance of entity. Click on ‘Akshay’, it will show popup to create entity for this instance. Give name to entity as ‘Person.name’ and click on create entity. It will update that utterance with entity name as follows.

Microsoft bot framework

You can add multiple utterances for ‘Search.People’ intent and add entity to it. (Please refer screenshot)

Microsoft bot framework

Now it’s time to test our app. Click on Train & Test in left hand sidebar and click on Train Application.

Microsoft bot framework

Console will be enabled after training, now start typing utterance and press enter to see result.

Query: ‘could you please search Akshay’, Result: App has identified intent as ‘Search.People’ and object as ‘Akshay’.

Microsoft bot framework

Query: ‘hello there’, Result: App has identified intent as ‘Greet.Welcome’.

Microsoft bot framework

Query: ‘bye’, Result: App has identified intent as ‘Greet.Farewell’.

Microsoft bot framework

Steps to create intelligent app

  1. Try and test multiple utterances.
  2. Find utterances for which app failed to find intended 'intent'.
  3. Educate the app for those utterances.

In next part, we will see how to publish this app to HTTP endpoint and consume it in Bot application created using Microsoft Bot Framework.

X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now