Skip to content

Latest commit

 

History

History
267 lines (161 loc) · 14.9 KB

File metadata and controls

267 lines (161 loc) · 14.9 KB
languages products page_type level role description
csharp
dynamics-customer-service
sample
beginner
developer
Sample that shows how to implement a custom smart bot for suggesting knowledge based articles and appointments in Dynamics 365 Customer Service.

Build a smart assist bot

Getting Started

This sample code contains custom smart bot implementation for suggesting knowledge base articles and appointment.

1. Deploying a new Smart Assist Bot

To develop a new web application based smart-assist bot, follow the steps mentioned below.

1. Download the GitHub sample code

This setup broadly contains the following steps.

  1. Update the values in appsettings.json
  2. Publish the webapp to Azure
  3. Update the Messaging endpoint in Bot channels registration
  4. Enable Teams channel
  5. Test your Bot online
  6. Smart Assist Admin Configuration

2. Update appsettings.json

Open Appsettings.json through solution explorer for the solution opened in Visual Studio, and update the LUIS, Bot and CDS settings following the steps mentioned below.

  1. LUIS Settings

LUIS app settings can be left blank for this sample scenario.

    // LUIS connection settings
    "LuisAPIHostName": "westus.api.cognitive.microsoft.com",
    "LuisAPIKey": "", // LUIS APP Key
    "LuisAppId": "", // LUIS APP ID

Follow the instructions mentioned in topic Add natural language understanding to your bot to add LUIS to your bot. Once you have created a LUIS app, see this section to get LuisAppId, LuisAPIKey and LuiAPIHostName.

Sample screenshots

You can create intents according to your scenario. Here we demonstrate how you can create intent for appointment.

  1. BOT Settings

    Register your bot with Azure Bot Service and obtain the Microsoft App ID and a Client secret as illustrated below.

    a. Create registration resource following the instructions mentioned in the topic Register a bot with Azure Bot Service.

b. Go to the resource which is just created and select settings from left pane and then click on **Manage** as shown in the screenshot below.<br />

c. Generate `Client secret` as mentioned in the section [Get registration password](https://docs.microsoft.com/azure/bot-service/bot-service-quickstart-registration?view=azure-bot-service-3.0#get-registration-password) and copy it separately. This will be your _MicrosoftAppPassword_<br />

d. Now click on **Overview** from left pane and copy the _Application(client) ID_. Update both the `Microsoft App ID` and `MicrosoftAppPassword` in appsettings.json.

```json
  // Bot settings
  "MicrosoftAppId": "<Microsoft App Id as copied in step 2d>",
  "MicrosoftAppPassword": "<Microsoft App password as copied in step 2c>",
  "REMOTEDEBUGGINGVERSION": "15.0.28307.222",
  "ScmType": "None"```
```
  1. CDS settings

    a. Login to Azure portal with Common Data Service credentials.

    b. Create an azure application to access Power Apps Common Data Service using the information provided in the section Create an application registration.

    See the screenshots given below for reference.

c. Copy the `Application (client) ID` and `tenant ID`.<br />

d. Copy the `Client secret`<br />

e. Add API permissions to this app inorder to access CDS capabilities

f. Update the copied App Id, tenant ID and client secret to the appsettings.json file.

    ```//Dynamics connection settings
    "DynamicsAppId": "<Azure Application Id copied in step 3c, This enables Bot to talk to CDS>",
    "DynamicsAppSecret": "<App secret for CDS App Id copied in step 3d>",
    "DynamicsOrgUrl": "<CDS Org Url>",
    "TenantId": "<CDS Tenant Id>"
    ```

Use the same app ID that you created earlier using the instructions in the topic Create a bot user. Also if your bot needs to search for knowledge base articles, then you need to provide either the Customer Service Manager or Customer Service Representative role to your bot user.

3. Publish your WebApp to Azure

  • Build your code and publish from Visual Studio using the instructions mentioned in topic Publish a Web app to Azure App Service using Visual Studio.
  • Copy the WebApp's endpoint that opens in a browser after publishing. For instance, web app endpoint can be something like https://smartassistbot2020.azurewebsites.net/.
    You can also copy the endpoint from Azure Portal.

Go to your web app and select Overview from left pane, as shown in the screenshot below.

4. Update Messaging endpoint of Bot channels registration

  • Now update the Messaging endpoint of Bot channels registration, created in 2(b) above with the WebApps messaging endpoint created in previous step Messaging endpoint will be WebApp Endpoint + /api/messages (i.e)
    In our Example, it will be : https://smartassistbot2020.azurewebsites.net/api/messages

5. Add supported channels

To use the bot over messaging channels:

6. Test your Smart assist bot

  • Test your bot online using Test in Web Chat option. See the section Test the bot for more details.

  • Type in omnichannelfoobar which will set the required flag to test online.

  • You can use keywords like travel, book or audio equipment to see the smart suggestions.

Note: If you are using a power virtual agent to answer customer facing queries and have added another smart assist bot for giving agent facing recommendations, type in "omnichannelfoobar" while testing your bot which will set the required flag to test online.


Custom Actions

In this sample, KB suggestion card contains two action buttons.

  • Send : Copies the KBLink to conversation control
  • Open : Opens up the KB article in a new browser tab

You need to update the website URL value in the variable called 'WebsiteURL' here - KBSearchOperation.cs

Both the actions will work by default and is handled in omnichannel side. You can also create custom action based on any scenario.

Steps to create a custom scenario for smart assist bot

Follow the instructions mentioned in the topic Implement a custom scenario for smart assist bot to be able to get similar case recommendations for ‘printer noise’ issue in smart assist while interacting with a customer as an agent in Omnichannel for Customer Service.

7. Smart Assist admin configuration

After you have built and tested the bot, follow the steps mentioned in the Smart assist for admins topic to enable Smart Assist in Omnichannel for Customer Service.

See also