Skip to main content
Microsoft logo
Power Apps
    • AI Builder
    • Automate processes
    • Azure + Power Apps
    • Build apps
    • Connect data
    • Portals
  • Pricing
    • Overview
    • Become a Partner
    • Find a Partner
    • Find consulting services
    • Blog
    • Customer stories
    • Documentation
    • Roadmap
    • Self-paced learning
    • Webinars
    • Overview
    • Issues
    • Give feedback
    • Overview
    • Forums
    • Galleries
    • Submit ideas
    • Register
    • ·
    • Sign In
    • ·
    • Help
    Go To
    • Power Apps Community
    • Get Help with Power Apps
    • Building Power Apps
    • Microsoft Dataverse
    • AI Builder
    • Power Apps Governance and Administering
    • Power Apps Pro Dev & ISV
    • Power Apps Portals
    • Power Platform Integration - Better Together!
    • Power Platform Integrations
    • Power Platform and Dynamics 365 Integrations
    • Community Blog & News
    • News & Announcements
    • Power Apps Community Demo Extravaganza 2020
    • Galleries
    • Community App Samples
    • Webinars and Video Gallery
    • Canvas Apps Components Samples
    • Kid Zone
    • Business Value Webinars and Video Gallery
    • Emergency Response Gallery
    • 2019 Microsoft Business Applications Summit Recordings (Archived)
    • Microsoft Business Applications Summit 2020 Session Recordings
    • Ideas
    • Power Apps Ideas
    • Community Support
    • Community Accounts & Registration
    • Using the Community
    • Community Feedback
    cancel
    Turn on suggestions
    Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
    Showing results for 
    Search instead for 
    Did you mean: 
    • Power Apps Community
    • Galleries
    • Community App Samples
    • Chat Bot with PowerApps + Flow + LUIS

    Chat Bot with PowerApps + Flow + LUIS

    10-09-2020 22:33 PM

    PowerWizard
    Regular Visitor
    482 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    PowerWizard
    PowerWizard
    Regular Visitor
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    Chat Bot with PowerApps + Flow + LUIS

    ‎10-09-2020 10:33 PM

    Chatbots are becoming widely implemented by corporations as they are one of the most advanced expressions of interaction between humans and machines, there are tons of options for creating chatbots similar to Power Virtual Agents. in this post I'm trying to demonstrate a low cost method of developing a chatbot with PowerApps, Power Automate, LUIS, and SharePoint. SharePoint is for data saving purpose only you can use CDS, Azure SQL etc.

     

    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 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 BotKnowledge 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 BotKnowledge in the SharePoint BotKnowledge List is the intents listed in LUIS. The response that you want to send to the user is in a field called “BotKnowledge ” in the BotKnowledge 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 (BotKnowledge ). 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 BotKnowledge . 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 Chatbot. Then, test your Chatbot by running PowerApps and Flow with a query.

    This is your 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 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  Chatbot can easily be generated with LUIS, SharePoint Online, SharePoint Lists, Flow, and PowerApps.

     

    PowerWizard

     

    NB: Feel free to connect for any doubts or samples

     

     

     

     

    Labels:
    • Labels:
    • Galleries and forms
    • Workflow and process automation
    Message 1 of 2
    482 Views
    1 Kudo
    Reply
    • All posts
    • Previous Topic
    • Next Topic
    mdevaney
    Super User III mdevaney
    Super User III
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎10-14-2020 05:00 AM

    @PowerWizard 

    Hello there.  I don't see any download link for an app here.  Was there supposed to be an app to download here or was this meant to be an article?  Its obvious that you've put a good deal of effort into piece but this area is meant for downloadable sample apps.  Please let me know so we can find the best place on this website for your work.

    Message 2 of 2
    400 Views
    1 Kudo
    Reply

    Power Platform

    • Overview
    • Power BI
    • Power Apps
    • Power Automate
    • Power Virtual Agents

    Power Apps

    • Sign in
    • Sign up

    Browse

    • Sample apps
    • Services

    Downloads

    • Studio
    • iOS
    • Android

    Learn

    • Documentation
    • Support
    • Community
    • Give feedback
    • Blog
    • Partners

    • © 2021 Microsoft
    • Follow Power Apps
    • Privacy & cookies
    • Manage cookies
    • Terms of use
    • Trademarks