Example configuration Microsoft Power Automate to setup an Automated QnA Email bot
A (Service) Microsoft account with Outlook that the bot can use to send emails from
A Microsoft QnA Maker set up, filled with a knowledge base (KB). We suggest creating a KB from previous questions stripped from emails linked to the correct answer
In this guide you will create a Microsoft Power Automate solution, in which you create a Flow that will answer incoming emails based on a Knowledge Base. If your bot is not sure about the answer it should propose, it will pass the email to the Anywhere365 Email Dialogue Provider or Anywhere365 TextHandler.
Creating the Flow
The trigger for this flow is determined by your email setup. For this guide we used “When a new email arrives in a Shared mailbox”, an Office 365 Outlook trigger event. Make sure you are signed in with the service account; that is has enough rights to read and answer emails. The service account will send out reply’s under its name, not under the name of the shared mailbox.
Select the folder you want the Flow to check for new emails, or leave it on Inbox.
Create an empty variable
Here you create an empty variable for the flow to call upon in a later stage. Add an action “Initialize variable” and name it. As type select “Array” and leave the value blank.
The first action is completely optional. If you are receiving emails in the shared mailbox that you don’t want the bot to handle, you can filter them out with an action called “Condition”. In the first field select an output of the Trigger, such as Subject. Select an operator and a value to compare to. If you are using multiple conditions, change the condition from “And” to “Or”.
Convert HTML To Text
If you have conditions in place, all the following steps will be placed under the “If no” side of the condition. If you do not have any conditions, they will be placed directly under the trigger.
For the HTTP request in the next step to work correctly you need to change from HTML script to plain text. Add an action called “HTML to text”; add the output from the trigger “Body” to the content.
Call the QnA Maker
Add an action “Generate answer”, a QnA bot action type. The information for his step can be found in your KB, under “My Knowledge Bases”, press view code to see the HTTP Request information.
Knowledge Base Id: the id between ‘POST /knowledgebases/xxxx-xxxx-xxxxx-xxx/generateAnswer
Service Host: The https address in the second line (without Host in front)
Endpoint Key: the endpointKey in the third line
Question: The output from step 4
Leave the Top on 1, for it to return the highest possible answer.
Iterate over the answer(s)
As the output of the QnA Maker action is in the form of a JSON, the next step will be applied as a “Apply to Each”. Select the output “Answers” as input to iterate over. As there is only one answer, this iteration will only run once and impact on performance will be neglected.
This step will check if the score of the QnA Bot certainty is higher then your threshold. If it is, it will automatically send an reply to the sender. Please make sure you have tested if your knowledge base contains the necessary data to provide solid and correct answers.
Add another “Condition” action. This time select the “Answers Score” as first value and ‘is greater than or equal to’ as operator. The second value is the threshold value. Under the Expressions tab type “float()” and between the brackets fill in your threshold. If you want to test the flow, or you don’t want your bot to send automatic replies just yet, fill in a value of 101, as it’s certainty can never be higher than a hundred percent.
If the threshold has been met (greater than threshold)
If it is positive then you want your flow to send a reply to the customer. Add an action “Reply to email (V3)”. As message id select the message id output from the trigger. In the body you can type a template for the reply mail. Don’t forget to call on the answer by adding “Answers Answer”.
If the threshold is not met (less than the threshold)
If the QnA Maker is not sure about the answer, it will have a lower certainty. If the threshold isn’t met, the Flow should not send out a reply but instead route the mail to the Anywhere365 Email Dialogue provider or Anywhere365 Texthandler.
You can easily achieve this to move the email to another folder and have the products look at that folder instead of the inbox directly. Add a new action under the “If No” of the condition, called “Move email V2”. As messageid select the messageid of the initial email (under the trigger action). Select the folder that you desire and have the products look at that folder.
Did you find this page helpful?
Sorry about that
Why wasn't this helpful? (check all that apply)
Thank you for your feedback.
Thanks for taking the time to give us some feedback.