Saturday, 5 May 2018

Content Classification on Office 365 SharePoint using MS Flow and LUIS

Views
In this post, let us look how the Office 365 SharePoint list content can be classified using Microsoft Flow with the help of LUIS text prediction techniques. Text added to Office 365 SharePoint list are classified and saved back to SharePoint using Microsoft Flow and LUIS.

Consider a scenario of having queries list, and admin wants the queries to be auto classified before routing the queries for solution. Microsoft Flow provides a LUIS connector, which helps in predicting and classifying the text being saved to SharePoint.

Note: In a layman scenario on LUIS portal, categories will be intents and queries will be utterances.


Connecting SharePoint and LUIS using Flow


The solution consists of three steps.
  • Query is created on SharePoint: Flow is triggered, whenever a new item is created in the SharePoint list.
  • Query category is predicted using LUIS: Flow uses LUIS Get Prediction action for classifying the item created. The action predicts the data using the trained app created on the LUIS portal. The output of this step will be matching intents (predicted scores) with the relevant scores.
  • Query is updated with the category predicted: After classification, the top scoring intent from the above step is saved to the respective SharePoint list item’s category field.


Note: Initially app needs to be created on the LUIS portal, which will have necessary intents (categories) with few sample utterances (queries). Admins can train the LUIS app with necessary intents and utterances whenever required.


Let us look at the solution, with screenshots.


LUIS App for Content Classification:


Create the app on LUIS portal with necessary data trained. For example, in this case let us create a category (an intent) called “socialmedia”. And we will add some sample queries (utterances) to the category created.
  • Create new app with some meaningful name “contentClassification”
  • Create new intent with the name “socialmedia”
  • Add some utterances to the intent for training.

The following snapshot shows the intent created on the LUIS portal with some utterances.


Go to publish tab, and copy the key string for later use.


Microsoft Flow connecting Office 365 SharePoint list and LUIS App:


Go to the Microsoft Flow portal and create a new flow with blank template. The following steps to be configured on Microsoft Flow portal.
  • Select SharePoint connector and pick a trigger (In this case “when an item is created”).
  • Pick the site and list details (If SharePoint connection is not already added, the flow will ask for Office 365 SharePoint credentials. Provide the credentials).
  • Add new action.
    • Search for LUIS connector.
    • Select “LUIS - Get Prediction” action.
    • Fill in the connection name and API key (Key should be copied from the LUIS portal app, as explained above) in the respective fields.

    • Select the LUIS app Id and utterance text as SharePoint list title value (from the previous step)

  • Add new action
    • Select SharePoint connector
    • Select “SharePoint – Update item” action.
    • Fill the fields
      • site name and list name (the same details as entered before). 
      • ID can be added from the step 1 using dynamic content. 
      • Title (unchanged) – to be filled using step 1. (Updated because Title is a mandatory column in the SharePoint list) 
      • Category – top scoring intent name from step 2.

  • Provide the app name and save the flow. The following snapshot shows the full flow with trigger and actions.


Test the Flow:


Open the SharePoint list (to which we have linked the MS Flow with LUIS). Add new item with some Title field, for which category will be identified using MS Flow and LUIS. After few seconds, you will see the category column updated with the intent, which was updated using MS Flow and LUIS in the background.

#Office365 #SharePoint #MicrosoftFlow #Azure #LUIS