cancel
Showing results for 
Search instead for 
Did you mean: 
yashkamdar

Build your Own Support Desk by Smart Management of Emails using LUIS and Power Automate.

I have often wondered,  What if there was a way for us to talk to our systems in our own Natural Language.  What if our applications were able to Interpret and Understand our Language and then carry out Predefined tasks in an Intelligent manner by following a strict Prediction Model.

Well no more wondering as Microsoft has introduced “Language Understanding Intelligent Service” – LUIS.

LUIS is a cloud-based service to which you can apply customized machine learning capabilties by passing in Utterances (natural language) to predict overall Intent, and thereby pull out relevant detailed information.

 

In this article, we are taking a real world scenario where a Support team is trying to implement LUIS on a Common Shared Mailbox so that the Intelligent Service can read the Message Body of each email and based on the Prediction Model understand the correct Microsoft Team Channel where the email needs to be assigned.

 

Diag.jpg

To reduce the complexity, we will divide this article in two parts:

  1. Design and Train our LUIS Application.
  2. Create a Power Automate Solution for Implementing Smart Email Management based on LUIS Predictions.

 

Prerequisites-

Before you begin, please make sure the following prerequisites are in place:

 

Step 1 – Building the LUIS Application

  • Sign in to LUIS portal .
  • Once successfully signed in, on the page that appears select ‘+ New app for conversation’ as shown in the image below.

add

 

  • A pop up form appears where you need to fill in the basic details for the LUIS application like ‘Name‘, ‘Culture‘ basically the language which the LUIS application should expect and the ‘Description‘.
  • Once this information is filled up, Click on ‘Done‘.

app2

 

Step 2 – Utterances and Intents ??

We now proceed by creating Intents for our LUIS application but wait what exactly is an Intent you ask ???

  • An Intent represents an action that the user wants to perform.
  • If you remember the image we saw a couple of minutes before, the intent here is to classify emails. That’s it, let’s keep it simple. So when I say classify I need to know the categories for the classification right !! These categories will be our Intents.

 

  • We need to assign emails to one of the three categories which are our Intents, namely –
    • OnPremise team
    • Online team
    • Sales team

 

 

Step 2.1 Creating Intents

  • Picking up where we left, once your LUIS application has been created you will be navigated to a page where you will see an option called as ‘Intent‘ in the left navigation.
  • Select the ‘Intents‘ option and click on ‘+ Create‘ as shown in the image below-

intent1

  • On the Pop up box that opens up enter the correct ‘Intent name‘ and click on ‘Done‘.
  • Do this for ‘Ticket_OnPremise‘, ‘Ticket_Online‘ and ‘Sales‘.

ticketop

online

 

sales

 

 

Step 2.2 – Creating Utterances

  • Utterances are inputs from the user or a system that your LUIS application will receive.
  • The LUIS application needs to understand and interpret these utterances to extract intents and entities from them, and so it is extremely important to capture a variety of different example Utterances for each intent.
  • Basically you need to type in the Utterances i.e the expected words that your users will normally be writing in the email messages being received by your shared mailbox.
  • Navigate to the ‘Intents’ that we have created in Step 2.1 and start writing Utterances as shown in the image below.

 

sampleutterance

 

  • If you have closely observed the image above, I have written an Utterance

How do I decide the no. of Application, Web Front end and Search servers needed to be configured in my SharePoint 2019 environment

  • Once you write an Utterance and press Enter, LUIS starts breaking the Utterance and keeps a track of keywords inside the Utterance.
  • The more no. of times a particular word starts appearing in the sample Utterance the more confident the LUIS becomes in predicting the Intent and thus higher the Prediction score for a particular intent.

 

 

  • Please take a look at the sample Utterances across Intents that I have configured for our LUIS application.

 

Ticket_OnPremise Utterances –

 

score

 

Ticket_Online Utterances –

 

onlineut

 

Sales Utterances – 

 

salesut

 

  • Now that you have seen my sample Utterances, let’s go ahead and Train our LUIS application.
  • But WAIT !! Did you notice that in all the images above the ‘TRAIN‘ button at the top is showing a red color.
  • That is basically an intimation from the LUIS application for you that you have Untrained utterances registered against Intents in your LUIS application.

 

Step 3 – Train the LUIS application

  • Now that we have built up the basic structure of our LUIS application let us go ahead and train it. We have already been receiving intimations from the LUIS application that it has untrained utterances across intents present with it.
  • Just navigate to the top of the page and hit the ‘Train‘ button.
  • The LUIS application will start training itself and show you notification stating that it is collection the training data as shown in the image below-

train

 

 

  • Sit back and relax, it will take some time for the LUIS application to train itself.
  • Once the training is finished, the LUIS application will notify you that the training is completed.
  • Now it is time to test our LUIS application before we go ahead and Publish it.

 

 

Step 4 – Test the LUIS application

  • Click on the ‘Test’ button from the top navigation and it opens up a test environment for us as shown in the image below.
  • Here what we can do is type sample utterances once again and see if the LUIS applications (after training) is able to predict the Intents correctly.

train

 

 

  • Let’s for example type a sample utterance and hit Enter –

One of the actions in my Power Automate solution keeps failing

  • As you can see in the image below, LUIS quickly runs the test utterance and posts a result. It has correctly predicted that the correct intent is ‘Ticket_Online’ which is also the ‘Top-scoring Intent‘ with a score of 0.483 which is the highest still a poor confidence right now because this is just our first test.
  • You need to keep training the LUIS app with more and more utterances so that it’s confidence keeps increasing.

yo

 

 

  • Let’s go ahead and test another utterance and see if this time the confidence i.e ‘Intent Score‘ increases or not.

test2

 

  • There you go !!! If you observe this time the ‘Top-Scoring Intent’ has a score of 0.723 which simply means that the LUIS application is more confident not since the last utterance about the intent.
  • So basically the more utterances are passed, the more the LUIS application will become intelligent.

 

Step 5 – Publish the LUIS application

  • That’s it, we are done here.
  • If you think about it, now that you know the basics it is so easy to go ahead and configure a LUIS application which at the start may seem like a daunting task.
  • Just navigate to the top of your screen and click on the ‘Publish’ button.
  • A pop up form opens up asking for the Slot in which the LUIS application needs to be published, just select Production and click on Done.

 

publish

 

 

 

Next we will be creating a Power Automate solution to grab the ‘Prediction‘ and in turn the ‘CorrectIntent‘ exposed by the ‘LUIS application‘, based on which we will Automate Decision Making.

 

 

Let’s start configuring our Power Automate (Flow) solution then.

 

Step 1 – When a new email arrives

  • For the ‘Folder‘ as shown in the image below, select the appropriate folder of the mailbox using the ‘Folder menu‘ present in the right hand side.
  • The ‘Inbox‘ folder of the mailbox selected, as shown in the image below, is the same folder where all emails will be received/dropped before we go ahead and implement smart sorting using LUIS predictions.

Trigger.PNG

 

Step 2 – Get Prediction

  • For the ‘App Id‘ as shown in the image below, click on the drop down menu and from the list of LUIS applications, select the correct LUIS application present in your subscription.
  • For the ‘Utterance text‘, Navigate to the ‘Add dynamic content‘ line and choose ‘Subject‘ or ‘Body Preview‘ present inside ‘When a new email arrives‘ action.

 

GetPrediction.jpg

 

Step 3 – Initialize Variable

  • Next, Add an ‘Initialize Variable‘ action and for the ‘Name‘ as shown in the image below, enter ‘CorrectIntent‘.
  • For the ‘Type‘, select ‘String‘ from the drop down menu.

 

InitVar.jpg

 

Step 4 – Parse JSON

  • For the ‘Content‘ as shown in the image below, Navigate to the ‘Add dynamic content‘ line and choose LUIS Prediction available under the ‘Get Prediction‘ action.
  • For the ‘Schema‘, please enter the following schema-
{
    “type”: “object”,
    “properties”: {
        “query”: {
            “type”: “string”
        },
        “topScoringIntent”: {
            “type”: “object”,
            “properties”: {
                “intent”: {
                    “type”: “string”
                },
                “score”: {
                    “type”: “number”
                }
            }
        },
        “intents”: {
            “type”: “array”,
            “items”: {
                “type”: “object”,
                “properties”: {
                    “intent”: {
                        “type”: “string”
                    },
                    “score”: {
                        “type”: “number”
                    }
                },
                “required”: [
                    “intent”,
                    “score”
                ]
            }
        },
        “entities”: {
            “type”: “array”,
            “items”: {
                “type”: “object”,
                “properties”: {
                    “entity”: {
                        “type”: “string”
                    },
                    “type”: {
                        “type”: “string”
                    },
                    “startIndex”: {
                        “type”: “integer”
                    },
                    “endIndex”: {
                        “type”: “integer”
                    },
                    “score”: {
                        “type”: “number”
                    }
                },
                “required”: [
                    “entity”,
                    “type”,
                    “startIndex”,
                    “endIndex”,
                    “score”
                ]
            }
        }
    }
}

 

ParseJP.jpg

 

 

Step 5 – Compose

  • Next, Add a ‘Compose‘ action and for the ‘Inputs‘ as shown in the image below, Navigate to ‘Add dynamic content‘ line and choose ‘Intent‘ option available under ‘Parse JSON‘ action.

 

Compose.jpg

 

Step 6 – Set Variable

  • Now we will set the ‘CorrectIntent‘ variable created above.
  • For the ‘Name‘ as shown in the image below, select the variable ‘CorrectIntent‘ from the drop down menu.
  • For the ‘Value‘ as shown in the image below, Navigate to the ‘Add dynamic content line‘ and choose ‘Outputs‘ option available under the ‘Compose‘ action.

 

SetVar.jpg

 

Step 7 – Switch case

  • Next, add a ‘Switch‘ conditional action.
  • For the ‘On‘ field as shown in the image below, Navigate to the ‘Add dynamic content‘ line and select ‘CorrectIntent‘ available inside the ‘Variables‘ section.
  • Basically what we are doing here is matching the CorrectIntent i.e the Intent that has scored the highest among all the intents based on the pre-trained prediction model.
  • When the ‘CorrectIntent‘ matches the ‘Equals‘ parameter it will switch to that particular case.
  • If you closely observe the ‘Cases‘, the names for each Case is same as that of the Intents created in the LUIS application that we deployed earlier in part 1.
  • Since we want to assign email message to a particular Microsoft team channel based on the LUIS Predictions and CorrectIntent let’s go ahead and create some channels.
  • As shown in the image below, add ‘Post a message‘ action inside each of the Cases.
  • For the ‘Team‘, select the correct Team from the drop down menu. Similarly for the ‘Channel‘ select the appropriate team channel from the drop down menu.
  • In the ‘Message‘ field inside the ‘Post a message‘ action as shown in the image below, configure a message and navigate to the ‘Add dynamic content‘ line and choose ‘Utterance text‘ available inside the Get Prediction action so that the message present in the received email gets copied.

 

Post.jpg

 

 

Now that we have configured the Power Automate solution, let’s forward an email message to our Shared Mailbox folder and check if the LUIS application is indeed able to correctly predict the Intent and based on CorrectIntent if the message gets posted in the correct Microsoft Team channel.

 

Email sent to the Inbox folder of the Shared Mailbox-

 

Email.jpg

 

 

Scores for different Intents as predicted by LUIS and Top scoring Intent-

 

IntentScoring.jpg

 

 

TopScore.jpg

 

 

Email message smart sort and uploaded as a message in correct Microsoft Team channel-

 

 

FinalOutput.jpg

 

 

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/