Updating QnA Maker knowledge base via SharePoint Online using Logic Apps!

This past week I had an interesting request from a customer of mine to assist them with implementing a solution to allow their master HR Q&A list (currently hosted on SharePoint) to be synced with their QnA Maker knowledge base powering their upcoming QnA bot for their internal employees. Current process of manually syncing the changes was tedious and time consuming for IT and dev resources and team was looking for a solution to automate this process!

After reviewing the existing flow we decided to help them build a proof of concepts using Azure Logic Apps and long and behold our customer was in shock on how easy it was to complete this task and how flexible this great Azure offering is (As a long time fan since early inception I was not surprised!)

Our very first step was to leverage QnA Maker API and build/validate couple of PUT, PATCH operations against their staging knowledgebase using Postman:

Next we created a logic app and started by leveraging a SharePoint Insert/Updated trigger using exiting SharePoint connector to have knowledge base updated for each insert or update to the SharePoint list! by leveraging the HTTP connector and using QnA API :

As shown above a simple condition rule (checking if Created column equals to Modified) allowed us to cover both insert and update flow within one logic app!

While insert was an easy task the challenge came up with updating the entries in knowledge base. By design each entry is assigned an id in which needs to be used when doing a PATCH to correctly update the right QnA entry within targeted knowledge base and to do this we ended up defining a dependency between each SharePoint list item (SharePoint list item id ) as a metadata during insert and use the same metadata (sp_id) to get the right item on knowledgebase for update operation!

To query the knowledge base we ended up using Download Knowledgebase operation and used Data Operation connector to parse and query JSON and pick the right item with checking the value of sp_id metadata and then make the update using Update Knowledgebase operation!

And of course notifying the user via Teams or Email!

To further enhance the process we proposed implementing an Azure Function to be used instead of data connector and provide better performance specially with large knowledgebase repositories!

And there you have it Azure serverless (Logic Apps and Azure Function saving the day yet again!)

Originally published at blogs.msdn.microsoft.com on June 26, 2018.