languages | products | page_type | level | role | description | ||
---|---|---|---|---|---|---|---|
|
|
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. |
This sample code contains custom smart bot implementation for suggesting knowledge base articles and appointment.
To develop a new web application based smart-assist bot, follow the steps mentioned below.
- Download the sample from the GitHub repository of Dynamics 365 apps sample code.
- Unzip the downloaded file and go to directory Dynamics365-Apps-Samples\customer-service\omnichannel\smart-assist-bot\SmartAssistBot.
- Open the solution file SmartBot.sln.(https://github.com/microsoft/Dynamics365-Apps-Samples/blob/master/customer-service/omnichannel/smart-assist-bot/SmartAssistBot/CoreBot.sln) in Microsoft Visual Studio 2017 or above.
This setup broadly contains the following steps.
- Update the values in appsettings.json
- Publish the webapp to Azure
- Update the Messaging endpoint in Bot channels registration
- Enable Teams channel
- Test your Bot online
- Smart Assist Admin Configuration
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.
- 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.
-
BOT Settings
Register your bot with Azure Bot Service and obtain the Microsoft
App ID
and aClient 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"```
```
-
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.
- 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.
- 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
To use the bot over messaging channels:
- Add Omnichannel channel as a supported channel, if you're using public cloud services.
- Add both Omnichannel channel and Microsoft Teams as supported channels, if you're using GCC (Government Community Cloud) services.
-
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
oraudio 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.
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.
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.
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.