Building an FAQ Chatbot in SharePoint

What exactly is a Chatbot? Through the advancement of artificial intelligence (AI) software, chats, or conversations, in natural language can occur between a user and applications like messaging apps, virtual assistants, websites, telephone, and mobile apps. The most common and recognizable Chatbots are Cortana, Siri, and Alexa.

Chatbots are becoming widely implemented by corporations as they are one of the most advanced expressions of interaction between humans and machines. This provides enterprises the opportunities to practice wise resourcing and reduce costs of staffing support while providing excellent, streamlined, and dependable user support. Though chatbots are automated, human intervention is still crucial to their success. They still require configuration, training, and system optimization.

A chatbot is composed of two parts. The first is a user’s query that is analyzed. Once analyzed, the second part occurs which entails the response which is sent to the user. Though this sounds simplistic, it is not as beneath this “simple exchange” are complex mechanisms that invisibly take place without the user’s awareness.

The very first step is the ability of the AI software to determine the intent of the user, analyze the request, and extract data based on the intent. This is the most important function of your chatbot. If the intent of the user cannot be understood, then a response to the query cannot be given. However, if done correctly, the most appropriate response will be provided to the user. The response can be retrieved from several different sources including predefined generic text, text retrieved from a knowledge database, data stored in an enterprise, contextualized information based on data from user input, or from actions that the chatbot had previously performed through other interactions with one or more backend applications.

Microsoft has been using the combined powers of machine learning and AI in SharePoint and Office 365 and a FAQ Chatbot is a next step in this evolution. A FAQ Chatbot can be generated by utilizing LUIS, SharePoint Online, PowerApps, and Flow.

LUIS is the heart of your bot as it is the machine learning based service that is used to build natural language into bots, apps, and IoT devices. LUIS allows you to configure questions that your users might answer to determine their intent. The type and configuration of utterances (the input from the user that the app needs to interpret) should be considered when configuring LUIS. Utterance length, such as short, medium, and long, can play an important role. The phrase length can be long, such as full sentences, or short, such as keyword searches. The word can be truncated from full text to acronyms or abbreviations. Other variances to consider are spelling, grammar, stemming, pluralization, noun and verb choice, punctuation, and word placement.  A solution and a consideration for misspelled words is the provisioning of a spell checker, like Bing Spell Check, that will allow the user to correct the word spelling before hitting the submit button. The more utterances you configure with LUIS, the higher the probability that LUIS will be able to identify the user’s intent. One key thing to remember is that users may not have the domain experience of the question that they are querying, and it is important to create phrases and use terminology that the majority of users will use.

While LUIS determines a user’s intent, or what they are asking, SharePoint Online, rather SharePoint Lists, is used to store the responses from the Chatbot by using the intent keywords returned by LUIS. By employing SharePoint Lists, users without an Azure account will be able to maintain the responses of the bot while allowing the creation of rich text formatted responses. SharePoint List will return the response content of the intents of the users and users will be able to maintain responses within SharePoint without having to go to any other tool to do so.

To begin creating the FAQ Chatbot, you will need to create an app in LUIS to store your intents. Next, you will need to create a list in SharePoint Online to store the response content for the intents.

The most efficient way of building the bot is to create it in Flow as Flow will do most of the work. Once the bot is created in Flow, the next step would be to connect Flow with PowerApps to make it run.

Create the Flow

  1. Create a New Flow. Choose Blank;
  2. Choose PowerApps as the trigger. Next, Add New Step;
  3. Add an Action, such as Send it to LUIS. Note that there are already LUIS actions available to choose;
  4. Open the LUIS application. At the top, click on the “Manage” tab. You will be taken to the Application Information page where the LUIS application ID can be found. Copy and paste the LUIS application ID into the Flow content box that requires this ID;
  5. Complete Utterance Text, which is the question being asked that needs to be passed to LUIS to get the intent. This comes from PowerApps. On the text box, choose Dynamic Content and a section for PowerApps will come up. Next, click on the tab “See More”. This will now provide a selection to Ask in PowerApps. By clicking this, the question will now come from PowerApps; and
  6. Specify the desired intent to be saved. There are several value choices plus an option to customize the value. Choose “None”.

Once this step is completed, the functionality is written to get an intent from a user when they ask a question in PowerApps.

The next step of the process is to take the intent and query the SharePoint List by that intent to get the correct or most probable response. Intents will be listed in LUIS. Your SharePoint List, titled FAQ List, will have the title field that is the same as the intent that exists in LUIS. In other words, the Title Field of the FAQ in the SharePoint FAQ List is the intents listed in LUIS. The response that you want to send to the user is in a field called “FAQ” in the FAQ List.

We now need to query SharePoint from Flow. Start by searching “SharePoint Get Items” which will populate a drop-down list with the site that houses your list (FAQ). Choose the site that has your list. Then, choose the type of filter query. In this instance, you can set the query so that the title field equals the intent. An example can have the Filter Title equal to the Top Scoring Intent Name, and this comes from LUIS. There should always be only one entry for the Top Scoring Intent Name, so chose the top One Count.

A variable will now need to be created to store this response in to pass that variable back to PowerApps. To do this, create a New Action to initialize a variable called “Response”. Add a new step to set the variable. This is a separate step, and not created during initialization because it is based on a collection from the Get Items Query.

Set the Variable response to the value of the response of the query of the FAQ. This is the field that holds the response. Flow will automatically fill it and applying it to each variable as it does not know the number of items being returned.

The response is now stored in a variable called Response and it will now be passed back to PowerApps.

The final step in this process requires a Search for PowerApps. Choose to Respond to PowerApps with one of several options, including Respond with Text or Respond with the Name of the Variable (Response). Save the Chatbot query settings.

Create Display Form for the Flow

Up until now, these processes occur in the background, invisible to the user. Which leads us, now, to build the form in PowerApps:

  1. Create a New App. Choose a blank app as well as the phone layout so that it is mobile friendly;
  2. Insert Text Box which will be used by the user to enter their query. Set the parameters;
  3. Add a Submit button so that the user can send and activate the process; and
  4. Add HTML Text to Screen to display the response in text and not HTML.

These four pieces are required to display the response from Flow.

Connecting Flow and PowerApps

In the apps screen above, highlight the Submit button. Go to the Actions tab in the menu bar and select Flows. Choose the Flow that you just created. Once you choose this Flow, it will automatically be added to the function/formula line. It automatically adds it as it knows that information will be needed from PowerApps because it was told that information would be passing in the query that was entered. Note that the function/formula is incomplete, and to make it run, it must be completed. The value or question that the user enters in the text box will be passed in the run function. Enter textinput1.text. By doing so, it will now call the Flow, passing the question. The response that comes back from the Flow is in the form of a collection so we cannot set the response to a variable and display that variable.

Therefore, when the Flow is completed, a function called Clear Collect needs to be called. This function clears the variable in the collection and sets that collection variable to the results. Because the results of the Flow is a collection, the responses from that Flow can be stored in a variable called Responses in a collection.

What is happening is that we call the Flow, pass the question, receive the response, and that response is stored in a variable collection.

As we are storing this response in a collection, we need to be able to display that data as it is no longer a variable. This is done by inserting a data table. The data source for this table is the Response variable.

Open the function/formula line. Select the Response variable. This will populate into the formula line and in that formula, set the data to be the Response variable. The data table is set up as the data in a collection. Next, click on the link under the data slide out box. The data field Response will appear. Choose Response to add to the app. This will now tell it what data from that collection you want to display in the data table.

The final step of this whole process is to ensure that the data does not display as HTML by choosing to that response to be Display HTML Text Field. The response cannot be displayed from the data table because the response is not formulated with HTML and without the Display into an HTML Text Field, it will appear as gibberish to the user. The source of the HTML text box must be specified as the data table along with the response from that selected row in the formula. Finally, select “Hide Data Table” so it is not visible to the user.

Save your FAQ Chatbot. Then, test your FAQ Chatbot by running PowerApps and Flow with a query.

This is your FAQ Chatbot and it runs like this. Your user enters a question in the text box. Once completed, your user will hit the Submit button. The Submit button then calls a Flow, which then passes the value of the text box, returning a response into a collection variable called Response. This collection is then set as the data table and Flow will take the selected entry from the data table and display it in the HTML textbox. The user will now have a response to the query in a natural language.

An FAQ Chatbot is an essential part of any enterprise. It provides efficient, fast, and dependable user and client support. It allows your clients and users to perform independently, freeing up valuable resources, lowering staffing costs, and providing immediate answers. As you can see, a FAQ Chatbot can easily be generated with LUIS, SharePoint Online, SharePoint Lists, Flow, and PowerApps.

  • Saturday, March 30, 2019 By : Mike Maadarani   

    Leave a Reply

    Your email address will not be published. Required fields are marked *


    Please enter the CAPTCHA text

    0 comment