Module 4 Lesson 1- Lab 2B: Configuring Omnichannel
Overview
Dynamics 365 Omnichannel integration allows the patient to interact with Health Bot using the Dynamics 365 chat widget to access the medical knowledge and your custom scenarios. It also allows the escalation of a bot conversation to a live agent to continue the interaction. When escalating a conversation, Dynamics passes along the conversation history and the context to the agent.
This lab will focus on Lamna Healthcare Company.
As stated in the Lab 2A, Lamna Healthcare Company is seeking to streamline their patient engagement capabilities by implementing Azure Health Bot to help improve processes and services, such as entering medication requests. By allowing patients to interact with this service, Lamna Healthcare Company will move one step closer to their goal of improving patient outcomes while reducing overall costs.
In this lab, you’ll play the role of a Lamna Healthcare IT developer and use the Azure Health Bot you configured in Lab2A to integrate with Dynamics 365 Omnichannel. This will complete the work for a medication refill scenario.
Learning objectives
In this lab, you will:
- Configure Dynamics 365 Customer Service Omnichannel Live Chat
- Embed Azure Health Bot in a Power Apps Portal
- Extend Azure Health Bot with custom scenarios
Exercise 1: Configure Omnichannel Live Chat
In this exercise, you will be configuring live chat for Dynamics 365 Omnichannel for Customer Service. Omnichannel for Customer Service offers a suite of capabilities that extend the power of Dynamics 365 Customer Service Enterprise to enable organizations to instantly connect and engage with their customers across digital messaging channels.
In the following tasks, you will complete the following:
- Assign Omnichannel agent security role
- Create an Application User using the MCH Application Id and your Bot ID
- Configure Queues for Bot and Agent Users
- Configure a Context Variable and Routing rule to route the message either to a Bot or Agent.
Task 1: Assign Omnichannel Agent Security Role
-
[] While in the In-Private or Incognito window, navigate to +++https://make.powerapps.com/+++.
-
[] Ensure the correct environment from the upper right Environment dropdown is selected.
-
[] Select the gear icon in the upper right corner and navigate to Advanced Settings.
-
[] A new window should open and navigate to Dynamics 365. It may take a while to load. If it’s been longer than a minute, stop and reload the page. It should then load faster. It will land you in the Business Management section of Dynamics 365.
-
[] On the top command bar next to Dynamics 365, select Settings to open the drop-down, then select Security in the third column under System.
-
[] Under Security, select Users.
-
[] Switch the dropdown from Omnichannel Users to Enabled Users for the grid view so that your user will show in the list. You may have to select the ellipsis next to Chart Pane to open the contectual menu and select System Views to make the view dropdown visible. This may take several minutes for the page to display.
-
[] While in the Enabled User list, scroll to find the Mod Administrator or use the Search bar.
-
[] Select your user for the training and select Manage Roles on the top command bar.
-
[] If necessary, select the Omnichannel Agent roles to assign to your user and select OK.
Congratulations! You assigned the proper omnichannel agent role to your user to allow you to be a live agent in omnichannel.
Task 2: Create Health Bot User in Dynamics 365 Customer Service
We need two users to configure in Omnichannel for Dynamics 365 Customer Service:
- Health Bot User – This is the Azure Health Bot user we created in the previous exercise.
- Omnichannel Agent User – This is your current user whom you are logged into Dynamics 365. This will allow you to be a live agent in Customer Service who receives messages from portal users through Azure Bot escalations. Note: For official trainings, this is your assigned user, MOD Administrator.
In this task, you will create a Bot User which helps connect Azure Health Bot with Omnichannel live Chat.
-
[] Go to +++https://admin.powerplatform.microsoft.com+++. Select your MC4H Labs environment from the list
-
[] You will land on your environments detail page.
-
[] Select the Settings button on the top command bar.
-
[] Expand Users + permissions and select Application users.
-
[] Select (+) New app user button to create a new Application User.
-
[] Select (+) Add an app on the create screen that slides out on the right side.
-
[] Paste the Application ID (the Application (client) ID you obtained in the Azure portal for the supplied MCH Application ID) into the search box and select the app from the list. Select Add at the bottom right.
-
[] Select a Business unit from the dropdown list (the options in the list will be unique for each Dynamics 365 environment). Select Create at the bottom right.
-
[] Return to the Dynamics 365 User page, switch the view to Enabled Users. This may take several minutes for the page to display.
-
[] While in the Enabled User list, scroll to find your App user (this is your MCH user, not the MOD admin user) or use the Search bar. Double-click on the user or select the row and click Edit.
-
[] Change the form type from User to Application User above the User Name.
-
[] You will see a new form appear that aligns to an Application User.
- [] In the User Information section, enter or select the following information and select the Save icon in the bottom right corner:
- [] User type: Select Bot application user. This will display a new field to store the Bot application Id.
-
[] Bot application ID: This is the Azure Health BotId you copied when enabling the Teams channel. This field is displayed once the User Type is selected to be Bot application user.
-
[] Select Manage Roles on the command bar.
-
[] If necessary, assign the Omnichannel Agent role to the Bot User as you did for your own user in the previous task. This will allow the bot to act as an omnichannel agent like your user.
Congratulations! You successfully created a Bot User and assigned to it the Omnichannel Agent role.
Task 3: Create and Configure Omnichannel Queues
In this task, you will create and configure the omnichannel queues necessary to communicate with the correct bot or agent depending on the situation.
-
[] In http://make.powerapps.com, open the Omnichannel admin center app.
-
[] Select Queues on the left navigation bar.
-
[] Open Default Messaging Queue.
We will now associate the Default messaging queue with the Bot User so it will respond to incoming messages from customers without agent (human) intervention.
-
[] Select Add Existing User on the User (Agents) subgrid to add the Bot user you previously created.
-
[] In the Lookup Records pane, search for your Bot User (MCH Application) created in the earlier task.
-
[] Select the record from the list and select Add.
-
[] You should now see the Bot User (MCH Application) in the Users list. Save and close.
[!NOTE] Note: If the user does not populate after adding, make sure you assigned the omnichannel agent security role to the bot user in the previous task (it may take up to 15 minutes for changes to take effect).
-
[] Go back to the Queues grid. Select + New queue to create a new Queue.
- [] Give the new Queue the following details:
- [] Name: +++Escalate To Human+++
- [] Type: Messaging
- [] Group number: 1
-
[] Select Create.
-
[] A Users subgrid should appear. If your user is not visible, select Add Users in the subgrid.
-
[] Search for and add your MOD Administrator user to the queue. The user is now added to the queue with the agent role.
The queue Escalate To Human is created to manage and redirect the incoming messages from a user to a Customer Service (human) Agent when Bot sends the user through to a live agent.
Congratulations! You have created the necessary queue to escalate to human agent and added the appropriate users to each messaging queue.
Task 4: Update Live Work Stream with Context Variables and Routing Rules
Workstreams are containers to enrich, route, and assign work items. A workstream is associated with a channel, such as live chat, voice, or case. After a bot is added to a workstream, the incoming work item is first routed to the selected bot at runtime based off classification rules. For more information, see Create workstreams for unified routing on Microsoft Learn.
In this task, we will set up basic chat routing. This will allow for users to chat with a bot user in certain cases and a live human agent in other scenarios. The routing rules will allow chat to behave as follows:
- Route to Bot: Initial customer conversation is through Health Bot in the default messaging queue. When the chat bot is first opened, route to Default queue which only contains the bot user (agent).
- Human Routing Rule: When context variable EscalateToAgent is present and set to 1, we route to the queue that has only human users (agents) who can take over conversation.
-
[] Navigate to Workstreams.
-
[] Select + New Workstream on the command bar.
- [] Enter the following details for the new workstream and select Create:
- [] Name: +++Chat Workstream+++
- [] Type: Messaging
- [] Channel: Chat
-
[] Work distribution mode: Push
-
[] On the Chat Workstream record, you must set up your chat channel. Select Set up chat under Live chat.
- [] The Live Chat setup screen will open. Enter the channel details as follows and select Next.:
- [] Name: Chat Widget
-
[] Language: English – United States
-
[] On the following screen, toggle to enable Proactive chat.
-
[] Select Next to see the Behaviors settings you can customize for your bot, including automated messages and surveys. No need to customize anything here now.
-
[] Select Next to see the User features that can be defined for the bot. Nothing is needed here now.
-
[] Review your settings and select Create channel.
-
[] Once the chat channel is successfully created, copy the script of the chat widget, and save it somewhere like Notepad to add it to your website later. Select Done to close the wizard.
-
[] In your new Chat Workstream record, select Add Bot to add the Azure Health bot for initial routing.
-
[] Find and select your bot. Select Save and close.
-
[] Expand Advanced settings to see the Smart assist bots subgrid. Select Add Bot, ensure MCH Application is selected and select Save and close.
-
[] Now we want to define a new context variable and routing rule. Select + Add Context variable.
-
[] In the context variable flyout, select + Add to add new context variable.
- [] Create the new Context Variable with the following details and select Create:
- [] Name: +++EscalateToAgent+++
-
[] Type: Number
-
[] Close the context variable panel. You should now see the new EscalateToAgent context variable in the live chat workstream.
-
[] Select Advanced Settings to collapse to the main page.
-
[] In the Routing rules subgrid, next to Route to queues, select +Create ruleset.
- [] Create the new route-to-queues ruleset with the following details and select Create:
- [] Name: +++Human Agent+++
-
[] Queue: EscalateToHuman
-
[] In the new Human Agent queue ruleset, select + Create rule.
-
[] Name the new rule +++Human Agent Rule+++.
-
[] Under Conditions, choose Add related entity from the dropdown.
-
[] In the first two dropdowns, choose Context item value and Contains data. In the inline condition, choose EscalateToAgent Equals 1.
-
[] In the Route to queues section, choose Escalate to Human queue created previously.
-
[] The configured rule set is shown below. Select Create.
-
[] The Chat Workstream now has a Human Agent ruleset that will escalate to a human agent when the EscalateToAgent context variable is set to 1
Congratulations! You have created the proper context variable and routing rules that will allow customers to begin conversation with a health bot and escalate to a human agent.
Task 5: Create Chat Widget for Health Bot
-
[] Navigate to Chat.
-
[] Select +New Chat Widget.
-
[] Give the Chat Widget a Name (eg., Patient Portal Chat Widget).
-
[] Select Save.
-
[] After the record is saved, a Widget Code Snippet will be generated. Copy the code snippet and store it for later use.
Congratulations! In this exercise, you have successfully configured Customer Service Omnichannel Live chat by creating the necessary Users, Queues, Work Streams, Context Variables, Routing Rules, and Chat Widget. These all work together and allow patients to chat with a virtual health bot with the option to escalate up to a human agent if needed.
===
Exercise 2: Embed Health Bot in Power Apps Portal
In this exercise, you will be embedding the Omnichannel Chat Widget into the Power Apps Customer self-service portal using Portal Management configuration. In your environment, we created a Lamna Healthcare Company Portal using the Customer self-service portal template before deploying Microsoft Cloud for Healthcare. Now we will configure the chat widget to show on the customer website.
Customer self-service portal: A customer self-service portal enables customers to access self-service knowledge, support resources, view the progress of their cases, and provide feedback.
Portal Management: Application to help you get started with the advanced portal configuration. In this walk-through, you will learn how to configure Chat widget in Portal Management app.
-
[] In http://make.powerapps.com, open the Portal Management app.
-
[] Select Content Snippets in the left navigation pane
-
[] In Active Content Snippets, type: +++Chat+++ in the Search box and press Enter.
-
[] You will see two Chat Widget Code records retrieved in the list. Select to open the Chat Widget Code record related to Lamna Healthcare Patient Portal.
-
[] In the Chat Widget Code record associated with Lamna Healthcare Patient Portal, select Value (HTML) > Html tab and then paste the Chat Widget Code snippet that you copied and stored in Task 5 of Exercise 1.
-
[] Select Save & Close.
-
[] Now open the other Chat Widget Code associated with the Healthcare Patient Portal website.
-
[] In the Chat Widget Code record associated with the Healthcare Patient Portal, in the Value (HTML) > HTML tab, paste the same Chat Widget Code snippet that you copied and stored previously and added to the Lamna Healthcare Patient Portal chat widget code. Replace any value that may have already populated the field.
-
[] Select Save and Close.
Congratulations! In this exercise you have successfully updated the chat widget in the Power App Portal Content Snippets. With this configuration, the Health Bot will be visible on the Power Apps portal for both the customer self-service template and the healthcare patient portal template.
===
Exercise 3: Extend Azure Health Bot with Custom Scenarios
Dynamics 365 Omnichannel integration allows the patient to interact with Azure Health Bot using the Dynamics 365 chat widget to access the medical knowledge and your custom scenarios. It also, allows the escalation of a bot conversation to a live agent to continue the interaction. When escalating a conversation, Dynamics passes along the conversation history and the context to the agent.
In this exercise, you will be doing the following:
-
Designing the below Health Bot Scenario called MCH_PatientService
- Design another Health Bot Scenario called MCH_PatientServiceWelcome. This scenario holds the starting statement which will allow the user to invoke the MCH_PatientService scenario.
- Set the Automatic Welcome Scenario to be the MCH_PatientServiceWelcome custom scenario you create. This will begin the scenario when a user first interacts with the Health Bot.
Task 1: Create MCH_PatientService Scenario
In this task, you will create the MCH_PatientService bot scenario using the designer canvas.
-
[] Navigate back to the Azure Health Bot instance homepage where you set the bot settings. This is the portal management link you copied from the Azure portal.
-
[] Select to expand the side navigation bar. Navigate to Scenario > Manage.
-
[] Select + New button on the top ribbon.
- [] Provide the following details for the new health bot scenario and select Create:
- [] Name: +++MCH_PatientService+++
-
[] Scenario ID: +++MCH_PatientService+++
-
[] It should navigate you directly to the designer. If not, select the MCH_PatientService scenario in Scenarios > Manage to edit. Now let’s design the scenario conversation.
Step 1: Add Bot Introduction Statement
-
[] Select + Add element > Conversational elements > Statement to add a beginning Statement to the scenario to the editor.
-
[] Enter the Display Text: +++Hi there, I’m your Healthcare Assistant.+++
-
{} Select the pencil next to Statement in the top bar and change Title to Intro.
-
[] Select Save. You will see the intro statement added to the designer canvas. To edit it, you can double-click anytime.
Step 2: Add Prompt for Medication Request or Live Agent
This section prompts two buttons Medication Refill and Live Agent. When user click any one of the buttons it will set the appropriate text to the variable MedicationOrAgent.
-
[] Select Add element > Conversational elements > Prompt icon to add a prompt.
- [] Enter the following details:
- [] Display Text: +++Would you like to request a medication refill or chat with a live agent?+++
- [] Variable name: ++MedicationOrAgent++
- [] Data type: string
- [] Rename Title to +++MedOrAgent+++.
-
[] Select Add Cards.
-
[] Select Card Type as Hero Card. Leave title blank as we already prompted with display text.
-
[] Select Add Action button twice to add two actions.
- [] For the first action, select the following:
- [] Action type: imBack
- [] Action value: +++MedicationRefill+++
- [] Action title: +++”Medication Refill”+++
- [] For the second action, fill in the following:
- [] Action type: imBack
- [] Action value: +++LiveAgent+++
- [] Action title: +++“Live Agent”+++
-
[] Select Ok and then Save to get back to designer.
-
[] Select the bottom circle on Intro and drag it to the top circle on the new prompt, MedOrAgent to connect them. An arrow will automatically appear when you try to connect Intro and MedOrAgent boxes using ellipse pointer.
-
[] Select Save.
-
[] Select Run to see the output in the WebChat on the right.
-
[] Select the Refresh button on the title bar of the chat window to clear the chat for the next text.
Step 3: Add MedicationOrAgent Decision Branch
This section checks whether the user has clicked Medication Refill or Live Agent with the help of the variable MedicationOrAgent. It will redirect the message accordingly.
-
[] Add a Branch to the designer canvas.
-
[] Enter the following in the javascript Boolean expression: +++scenario.MedicationOrAgent === “MedicationRefill”+++
-
[] Rename to +++IsMedRefill+++. Select Save.
-
[] Select and drag the bottom circle of the MedOrAgent prompt to the top circle of the IsMedRefill branch decision to connect them. Select Save.
Step 4: Prompt User to Enter Data for Medication Refill Option
-
[] Add a Prompt element. This will be used to display the Form data (using Adaptive Card) to capture Patient name, email, and phone to create an appointment.
- [] Add the following details and select Add Cards:
- [] Input variable: +++formData+++
- [] Input Type: Object
- [] Change Title to +++Submit+++
-
[] Do not add any display text since the adaptive card will display instead
-
[] Select Adaptive Card in Card Type.
-
[] Refer to the lab resources file AdaptiveCardForMedicationRefill.txt and copy the json content and paste it in the json section of your card.
-
[] Select OK and Save to get back to the designer.
-
[] Connect the Yes condition of the IsMedRefill branch to the Submit prompt.
-
[] Save and run your current scenario. If you don’t save the scenario first, it won’t run with updates since the last save. If you haven’t saved at all, it won’t recognize any conversation.
-
[] Select the Medication Refill card when prompted. The AdaptiveCard will be displayed.
Step 5: Add Confirmation Statement
-
[] Add a Statement element.
-
[] Add Display text as the following: +++scenario.formData.myName + “ - Thanks for providing the information, we have created a Medication Request for you regarding the following medication: “ + scenario.formData.myMedReq+++
-
[] Rename the statement to +++Confirmation+++ and select Save.
-
[] Connect the Submit step to the Confirmation step in the designer canvas.
-
[] Select Save and select Refresh in the Web Chat pane. Select Run to see your scenario in the webchat.
-
[] Fill in information for the request and select Submit to see the confirmation text.
Step 6: Invoke Live Agent Action
-
[] Add a Statement element to the canvas.
-
[] Enter Display Text: +++Please wait, I am transferring your request to a live agent for further assistance.+++
-
[] Rename the statement to +++Live Chat+++
-
[] Select Save to return to the designer page.
-
[] Connect the No decision of the IsMedRefill branch to the Live Chat statement.
Step 7: Add Action to Invoke Escalation
-
[] Add an Action element to the canvas that will be used to trigger an escalation to Omnichannel Live Agent
-
[] Add the following code in the action, which will trigger the Live agent chat:
session.sendChannelData(‘Escalating…’, {
“tags”: JSON.stringify({type: “Escalate”, context: {“EscalateToAgent”: 1}})
});
-
[] Name the action +++Escalate+++. Select Save to return to the designer page.
-
[] Connect the Live Chat to the new EscalateToAgent action. You completed the final connection!
-
[] Save, refresh the chat, and run your scenario to see the full scenario output.
-
[] Select Live Agent in the authored card should show the escalation action.
-
[] Select the back arrow next to MCH_PatientSerivce in the scenario editor.
Task 2: Create MCH_PatientServiceWelcome Scenario
In this task, you will create another bot scenario called MCH_PatientServiceWelcome to invoke the MCH_PatientService scenario.
-
[] On the Azure Health Bot scenarios page, select +New to create another new scenario
- [] Provide the following details for the new scenario and select Create:
- [] Name: +++MCH_PatientServiceWelcome+++
-
[] Scenario ID: +++MCH_PatientServiceWelcome+++
-
[] On the scenario editor designer, add a Statement element.
-
[] Rename the statement Welcome. Do not add any Display text as we will show it in the card instead.
-
[] Select Add Cards.
-
[] Choose Hero Card. Add Title: +++Welcome to Lamna Healthcare Patient Service Portal+++
- [] Select Add Action and provide the following details:
- [] Action type: imBack
- [] Action value: +++”begin MCH_PatientService”+++
- [] Action title: +++”Lamna Healthcare Support”+++
-
[] Select OK and Save to view your completed scenario. This will be used to kick off the conversation and allow the other MCH_PatientService scenario to be invoked through the authored card.
-
[] Save and run to test your bot scenario MCH_PatientServiceWelcome scenario in the Web Chat.
- [] Select the back arrow next to MCH_PatientSerivce in the scenario editor.
Task 3: Configure Welcome Scenario as Automatic
In this task, we will set the MCH_ PatientServiceWelcome to be the “Automatic Welcome Scenario” in settings. This will always trigger the welcome scenario when a user starts a conversion with the Azure Health Bot.
-
[] Navigate to Configuration > Conversation
-
[] In the Interactions tab, scroll down to the Automatic Welcome section.
-
[] In the Automatic welcome scenario dropdown, select the MCH_PatientServiceWelcome. Select Save.
Task 4: Test Health Bot Escalation from Power Apps Portal to Dynamics 365 Omnichannel
-
[] Navigate to Power Apps and click to open Lamna Healthcare Patient Portal.
-
[] You should see the Health Bot Let’s Chat button in the lower right-hand corner of the screen. This means the chat widget was successfully embedded into the Customer Self-service portal.
-
[] When you the select the chat widget, the bot will trigger the welcome scenario message we created and set as the default welcome message (MCH_PatientServiceWelcome).
[!ALERT] Note: Omnichannel for Customer Chat Widget will work only when you see the presence status is enabled. There should be a splash loading screen that goes through multiple steps and then displays the status indicator as available once loaded. (Status is enabled when the green circle with the checkmark appears)
-
[] To verify the presence status, navigate back to Power Apps and open Customer Service Workspace.
Splash screen:
-
[] In the Health Bot in Lamna Healthcare Patient Portal, select Lamna Healthcare Support button, then the Live Agent button to witness the escalation into Omnichannel to chat with a live agent (your user!)
-
[] Navigating back to Omnichannel for Customer Service, your user as the Live Agent should receive an incoming notification with Accept/Reject options for that chat.
-
[] Select Accept to connect and chat with customer (In this case chat with the patient).
-
[] As soon as Live Chat Agent accepts the incoming chat notification, Omnichannel for Customer Service has opened a Live Chat Widget and Agent would be able to see the entire bot conversation with user and continue the chat conversation with user for further assistance.
Congratulations! You have successfully extended the Azure Health Bot with custom scenarios and tested the end-to-end escalation scenario from a patient using the Azure Health Bot in Power Apps Portals to chatting with a Live Agent in Omnichannel for Customer Service.