FAQ Bot – Refresh Content

In the previous post, we reviewed how to layer a bot on top of the knowledge articles created in Dynamics 365 using Dynamics 365 Portals and QnAMaker Cognitive Service. We extract the content from the portal url (as configured in the Step 4 of the QnAMaker Configuration) in order to create a Knowledge Base with question and answer pairs that our bot ultimately leverages.

Dynamics 365 Knowledge Articles to QnAMaker Knowledge Base

Our business is evolving and our business users keep editing and/or adding knowledge articles in Dynamics 365 as they see fit. So, what happens then? Will those changes be automatically reflected in the QnaMaker’s Knowledge Base? Unfortunately, the answer is No. When we setup the Knowledge Base in the QnAMaker using a webpage URL, it does not automatically refresh the QnAMaker’s Knowledge Base as the content changes. What we want is a continous sync between the Dynamics 365 knowledge articles with the QnAMaker Knowledge Base.

In this post, let’s review how to keep our QnAMaker Knowledge Base continuously synced/updated to match the FAQ content that the Portal url provides.

Here is the recipe:

First off, we need a mechanism to convey that there are changes to the Knowledge articles in Dynamics 365. We are going to employ Microsoft Flow for this purpose. This Flow will get triggered whenever a knowledge article is created or updated in Dynamics 365.

Once triggered, we need this flow to call the QnAMaker API to let it know the the current Knowledge Base content is stale and it needs to refresh the content again from the Portal URL.

Once all the above steps are done, flow calls the QnAMaker API to publish the Knowledge Base.

Alright. Let’s begin to review the above steps in detail.

Go to https://us.flow.microsoft.com/en-us/ and click on Create from blank button.

Choose Dynamics 365 connector and click on When a record is created or updated option.

Configure the Organization Name and Knowledge Articles as the Entity Name.

Call the QnAMaker Update Knowledge Base API.

  • Ocp-Apim-Subscription-Key – Key that is available to be copied from your QnAMaker Service configured through Azure. You can find this by navigating to Azure Portal -> Open the QnAMaker configured -> Keys.

Request Body – { “add”: { }, “delete”: { }, “update”: { “urls”: [“https://dhinatwofour.microsoftcrmportals.com/kb”%5D } }

We do not have any specific knowledge article to add or delete. We provide the same Portal URL in the update block so as to refresh all the content available in that particular URL. This way we sync the Knowledge Base in QnAMaker service with the Dynamics 365 Knowledge articles.

Finally, publish the Knowledge Base.

Follow the URI and the Subscription Key format as provided in the above step.

Now, go ahead and fire up the bot emulator and try it yourself. Every time the Knowledge article is modified or added in the Dynamics 365, this flow will help refresh the Knowledge Base content using QnAMaker’s API so that the FAQ content always stays up to date for the bot to serve your users with.

2 thoughts on “FAQ Bot – Refresh Content

  1. Hiya,

    Thank you for your very informative post 🙂

    Tried doing it with the excellent web-based API-tester here;
    https://westus.dev.cognitive.microsoft.com/docs/services/5a93fcf85b4ccd136866eb37/operations/5ac266295b4ccd1554da7600

    I am using this JSON-body:
    {
    “update”: {
    “urls”: [ “my_url_to_my_shared_sharepoint_document”
    ]
    }
    }

    And when I check the response of the operation using “Get Operation Details”;
    https://westus.dev.cognitive.microsoft.com/docs/services/5a93fcf85b4ccd136866eb37/operations/operations_getoperationdetails/console

    I see this response;

    Request-Context:
    X-Content-Type-Options: nosniff
    apim-request-id:
    Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
    Date: Fri, 04 Oct 2019 12:46:51 GMT
    X-Powered-By: ASP.NET
    Content-Length: 749
    Content-Type: application/json; charset=utf-8

    {
    “operationState”: “Failed”,
    “createdTimestamp”: “2019-10-04T12:45:46Z”,
    “lastActionTimestamp”: “2019-10-04T12:45:55Z”,
    “userId”: ,
    “operationId”: ,
    “errorResponse”: {
    “error”: {
    “code”: “BadArgument”,
    “message”: “Failed to extract QnAs from the source”,
    “details”: [{
    “code”: “ExtractionFailure”,
    “message”: “Unsupported / Invalid url(s). Failed to extract Q&A from the source”,
    “target”: “my_url_to_my_shared_sharepoint_document”
    }]
    }
    }
    }

    The URL are exactly the same as the current link to the shared Sharepoint document I have in my KB and if I check the “refresh” checkbox in the KB I am able to update it manually but not through the API.

    Any ideas?

    Thanks again for your post – Karl, Sweden

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s