Introduction 

Any business which transacts online requires providing some kind of chat support for the issues related to their business. This can be done by developing chat applications where the consumers directly chat with the agent of the business who then solve their problems. A new alternative to answering frequently asked questions is the use of the Chat Bot which is intelligent enough to understand the questions raised by the user and determine the solutions to them on the real-time basis.  Or in case of an administrator, if they are managing a lot of operative tasks or a lot of source code bases, then an intelligent bot is of great help.

For the bot to become intelligent, the important step is that the bot should understand the language in which humans communicate with the bot (e.g English, French, Hindi etc.). To facilitate this understanding Microsoft has provided developers with a powerful feature called as Language Understanding(LUIS). This feature can be used to understand the language by comparing the uttered sentence against the intents and the entities defined while creating the LUIS application. 

When the bot is being developed, the LUIS app can be consumed from the azure functions using the LUIS API or it can be consumed to get the predictions by calling the LUIS app from the logic app. This article will discuss the consumption of the LUIS app from the Logic App.

What are Logic Apps?

Logic Apps are a piece of integration workflow hosted on Azure which is used to create scale-able integrations between various systems. These are very easy to design and provide connectivity between various disparate systems using many out of the box connectors as well as with the facility to design custom connectors for specific purposes. This makes integration easier than ever as the design aspect of the earlier complex integrations is made easy with minimum steps required to get a workflow in place and get it running.

What is LUIS?

As per Microsoft 

"Language Understanding (LUIS) allows your application to understand what a person wants in their own words. LUIS uses machine learning to allow developers to build applications that can receive user input in natural language and extract meaning from it. A client application that converses with the user can pass user input to a LUIS app and receive relevant, detailed information back."

Key Concepts In LUIS

  1. Utterance: This is the actual command spoken/written by the User /APP
  2. Intents: Intents describes the actual intention behind the command given by the user.
    e.g. when the User says "Find me all the Push made on the PublicWorks Repository", what user wants is the list of the Push made on the PublicWorks repository, hence Push made is the intent here.
  3. Entity: This is extra information that is present in the utterance which helps the LUIS to understand the utterance more. In above e.g PublicWorks is the name of the repository and hence is the entity which gives the name of the repository on which the Push is to be queried.

↑Back To Top 



Scope 

This article focuses on creating a LUIS app which understands the various functions that can be performed on the repository. Once the intent to identify the action on the repository is created and the LUIS app trained and published, the LUIS app will be consumed from the Logic APP which will pass the utterance to the LUIS app and get the prediction form the LUIS app.

↑Back To Top 



Design

LUIS App

Following are the steps that need to be performed to create a LUIS app.

  1. Log on to the LUIS portal (https://www.LUIS.ai) using the Azure credentials.
  2. Create a LUIS application. Refer sample screenshot below.



  3. Create New Simple Entities RepoName and ActionAskedAbout as per the sample below.





  4. Create a composite Entity RepoAction which will encapsulate the entities created above. Refer following screen shot.



  5. Create an intent ActionsOnRepo to understand that the intent behind the utterance is to do/query certain action on a certain repository.



  6. The list of utterances used to train the app is as follows.




  7.  Map the Composite entity created above to the Utterances entered above. 
  8. Trains the LUIS app using the Train button in the portal. Once the App is trained, it can be tested using sample inputs.

LUIS Cognitive Service Account 

In order to consume the LUIS app from the logic apps, the LUIS app must be published to the Resource group so that logic app connectors can use it, in order to do so, a LUIS cognitive services account need to be set up in the Azure. Refer to following steps to set up the account.

  1. Select the Cognitive Services blade.



  2. Create the Account.


       

Publish LUIS App 

Once an account for LUIS is created, the publication of the app becomes very easy.  Navigate to the Publish Tab in the LUIS portal and select the environment (Production/Staging) and the time zone.

  

Select the region where the LUIS app needs to be Hosted and click Add Keys, this will allow the LUIS portal to link the LUIS app to the LUIS account created above.

   

Once done, click on the publish button, this will publish the LUIS app into the LUIS account created earlier.

The LUIS app is now available to be consumed by the Logic App.

Logic App

The logic app design is simple. Create a request-response Logic App and add the connection to the LUIS account by providing a name and the key for the user from the LUIS portal, the key for the user (Author ID) can be found under the User Setting as shown below.

Create the connection using this authoring key. Refer sample screenshot

   

Following is the complete design of the Logic App.

  

↑Back To Top 



Testing

Following message was fed to the Logic App from the PostMan.
{
    "Utterance" : "Please bring me all the pulls done on the PublicWorks repository"
}

The response generated by the Logic App was 

{
    "query": "Please bring me all the pulls done on the PublicWorks repository",
    "topScoringIntent": {
        "intent": "ActionsOnRepo",
        "score": 0.9880099
    },
    "intents": [
        {
            "intent": "ActionsOnRepo",
            "score": 0.9880099
        },
        {
            "intent": "Available Functions",
            "score": 0.009692609
        },
        {
            "intent": "None",
            "score": 0.00528933574
        }
    ],
    "entities": [
        {
            "entity": "pulls",
            "type": "ActionAskedAbout",
            "startIndex": 24,
            "endIndex": 28,
            "score": 0.9956364
        },
        {
            "entity": "pulls",
            "type": "RepoAction",
            "startIndex": 24,
            "endIndex": 28,
            "score": 0.9969615
        },
        {
            "entity": "publicworks",
            "type": "RepoAction",
            "startIndex": 42,
            "endIndex": 52,
            "score": 0.84949106
        },
        {
            "entity": "publicworks",
            "type": "RepoName",
            "startIndex": 42,
            "endIndex": 52,
            "score": 0.73795265
        }
    ],
    "compositeEntities": [
        {
            "parentType": "RepoAction",
            "value": "pulls",
            "children": [
                {
                    "type": "ActionAskedAbout",
                    "value": "pulls"
                }
            ]
        },
        {
            "parentType": "RepoAction",
            "value": "publicworks",
            "children": [
                {
                    "type": "RepoName",
                    "value": "publicworks"
                }
            ]
        }
    ],
    "luisPrediciton": "{\"query\":\"Please bring me all the pulls done on the PublicWorks repository\",\"topScoringIntent\":{\"intent\":\"ActionsOnRepo\",\"score\":0.9880099},\"intents\":[{\"intent\":\"ActionsOnRepo\",\"score\":0.9880099},{\"intent\":\"Available Functions\",\"score\":0.009692609},{\"intent\":\"None\",\"score\":0.00528933574}],\"entities\":[{\"entity\":\"pulls\",\"type\":\"ActionAskedAbout\",\"startIndex\":24,\"endIndex\":28,\"score\":0.9956364},{\"entity\":\"pulls\",\"type\":\"RepoAction\",\"startIndex\":24,\"endIndex\":28,\"score\":0.9969615},{\"entity\":\"publicworks\",\"type\":\"RepoAction\",\"startIndex\":42,\"endIndex\":52,\"score\":0.84949106},{\"entity\":\"publicworks\",\"type\":\"RepoName\",\"startIndex\":42,\"endIndex\":52,\"score\":0.73795265}],\"compositeEntities\":[{\"parentType\":\"RepoAction\",\"value\":\"pulls\",\"children\":[{\"type\":\"ActionAskedAbout\",\"value\":\"pulls\"}]},{\"parentType\":\"RepoAction\",\"value\":\"publicworks\",\"children\":[{\"type\":\"RepoName\",\"value\":\"publicworks\"}]}]}",
    "desiredIntent": "ActionsOnRepo",
    "isDesiredIntent": true
}

The response clearly indicates that the input utterance follows the intent "ActionsOnRepo" and the intent that the logic app was expecting from the utterance is as expected. The LUIS correctly predicted the name of the repository as the "publicworks" and the ActionAsked about as "Pulls". Following part of the response is indicative of that.

"compositeEntities": [
        {
            "parentType": "RepoAction",
            "value": "pulls",
            "children": [
                {
                    "type": "ActionAskedAbout",
                    "value": "pulls"
                }
            ]
        },
        {
            "parentType": "RepoAction",
            "value": "publicworks",
            "children": [
                {
                    "type": "RepoName",
                    "value": "publicworks"
                }
            ]

↑Back To Top 



Conclusion

As clear from the testing results, the LUIS app can be consumed to get the predictions about the Utterances provided to the Logic App.

↑Back To Top 



See Also

Refer following articles on TechNet wiki for more reading around LUIS.

↑Back To Top 



References

Following article was referred to quote information about LUIS.

About Language Understanding (LUIS)

↑Back To Top