Tutorial: Customize (csharp)

Update your knowledge bases

The Virtual Assistant Template includes two knowledge bases, FAQ and Chitchat, that can be customized to fit your scenario. For example, QnA Maker offers FAQ and PDF extraction to automatically build a knowledge base from your existing content (learn more).

There are also a variety of prebuilt chitchat knowledge bases with different personality types (learn more).

Learn how to edit a knowledge base in the QnA Maker portal. After publishing your desired changes, your Virtual Assistant Dispatch model will need to be updated with your changes. Run the following command from your project directory to update your Dispatch model:

.\Deployment\Scripts\update_cognitive_models.ps1 -RemoteToLocal

This script updates your local .lu files with any changes in made in the QnA Maker or LUIS portals, then runs dispatch refresh to update your Dispatch model with the changes.

Add an additional knowledge base

You may wish to add an additional QnA Maker knowledge base to your assistant, this can be performed through the following steps.

  1. Create your new knowledge base using the QnAMaker portal. You can alternatively create this from a new .lu file by adding that file to the corresponding resource folder. For example, if you are using an English resource, you should place it in the deployment/resources/QnA/en-us folder. To understand how to create a knowledge base from a .lu file using the ludown and qnamaker CLI tools please refer to this blog post for more information.

  2. Update the cognitiveModels.json file in the root of your project with a new entry for your newly created QnA Maker knowledge base, an example is shown below:

           "id": "YOUR_KB_ID",
           "name": "YOUR_KB_ID",
           "kbId": "",
           "subscriptionKey": "",
           "hostname": "https://YOUR_NAME-qnahost.azurewebsites.net",
           "endpointKey": ""

    The kbID, hostname and endpointKey can all be found within the Publish page on the QnA Maker portal. The subscription key is available from your QnA resource in the Azure Portal.

  3. The final step is to update your dispatch model and associated strongly typed class (LuisGen). We have provided the update_cognitive_models.ps1 script to simplify this for you. The optional -RemoteToLocal parameter will generate the matching LU file on disk for your new knowledgebase (if you created using portal). The script will then refresh the dispatcher.

    Run the following command from within Powershell (pwsh.exe) within your project directory.

         ./Deployment/Scripts/update_cognitive_models.ps1 -RemoteToLocal
  4. Update the Dialogs/MainDialog.cs file to include the corresponding Dispatch intent for your new QnA source following the existing examples provided.

You can now leverage multiple QnA sources as a part of your assistant’s knowledge.

Update your local LU files for LUIS and QnAMaker

As you build out your assistant you will likely update the LUIS models and QnA Maker knowledge bases for your Assistant in the respective portals. You’ll then need to ensure the LU files representing your LUIS models in source control are kept up to date. We have provided the following script to refresh the local LU files for your project which is driven by the sources in your cognitiveModels.json file.

Run the following command from within Powershell (pwsh.exe) within your project directory.

    ./Deployment/Scripts/update_cognitive_models.ps1 -RemoteToLocal