Before you Begin

Background

In this two-hour lab, you'll learn how to work with skills and digital assistants in Oracle Digital Assistant.

  • A skill is an individual chatbot that is focused on a specific set of capabilities (e.g. helping customers order food from a specific restaurant).
  • A digital assistant is a master chatbot containing multiple specialized skills. When a user engages with the digital assistant, the digital assistant evaluates the user input and routes the conversation to the appropriate skill. You can populate your digital assistant with skills from the Skill Store and with skills you have designed yourself.

Here’s the scenario for this lab:

You’re part of a project team building a digital assistant to allow your customers to better engage with the various businesses in a major shopping centre.

This is the early stage of building the digital assistant and currently it supports use cases for a bank and a major retail store. The next stage of the project is to add a skill to support the new pizzeria that is opening up.

Here is what you need to do:

  • Complete the pizza skill ensuring it can handle complex requests for personalizing your pizza.
  • Add this skill to the shopping centre digital assistant.
  • Expose the digital assistant on the pizzeria's website.

What Do You Need?

To complete this lab, you need:

  • These files:

    Go ahead and download them now.

  • Oracle Web SDK 20.6.1 or later unzipped into a folder of your choice.

    You can download this SDK from the Oracle Digital Assistant downloads page.

  • One of the following supported browsers:
    • Firefox
    • Chrome
    • Safari
    • Edge
  • An Oracle Digital Assistant (ODA) cloud instance. You can get one using either of the following approaches:
    • Use your own instance.

      If you have your own instance, you can continue this lab after the event and even build your own digital assistant.

    • Using a shared instance. This option only applies if you are participating in an Oracle event where such an instance is available for all of the lab's participants.

      With this option, you can dig into the lab with less setup time.

Option A: Use Your Own Instance

Provision an Oracle Digital Assistant Instance

If you don't already have an instance of Oracle Digital Assistant, you can set one up through the Oracle Cloud Infrastructure Console.

If you will be the only user of this instance, you can do a simplified setup consisting of these basic steps:

  1. Using your Oracle Cloud Infrastructure admin credentials, sign into the Oracle Cloud Infrastructure Console.
  2. Create a compartment.
  3. Create a Digital Assistant instance in this compartment.

For a detailed walkthrough of this process, see this article.

Note: If you want to invite other users, you need to create user accounts, security roles and grant users permission to access to your instance. For more on this process, see Set Up Digital Assistant as an Individual Service.

Import the Starter Skill and Digital Assistant to Your Instance

Now let's prepare our demo environment by setting up the starter pizza skill and starter shopping centre digital assistant.

Import the Pizza Skill:

  1. With the Oracle Digital Assistant UI open in your browser, click main menu icon to open the side menu.
  2. Click Development and select Skills.
  3. Click main menu icon again to collapse the side menu.
  4. Import the skill by clicking the Import Skill button that is highlighted in red in the screenshot below.
    a screenshot of the Skills page. In the top navigation bar of the page there are buttons for Instant Apps and Import Skill.
  5. Navigate to PizzaSkill_starter.zip on your system and click Open.
  6. In the skills dashboard, select the PizzaSkill tile to open the skill designer.

Import the Starter Digital Assistant

  1. With the ODA UI open in your browser, click main menu icon to open the side menu.
  2. Click Development and select Digital Assistants.
  3. Click main menu icon again to collapse the side menu.
  4. Click Import Digital Assistant.
  5. Navigate to ODA_HOL2019.zip on your system and click Open.
  6. In the Digital Assistants dashboard, select the ODA_HOL2019 tile to open the DA designer.

    If you cannot spot the ODA_HOL2019 DA, type ODA_HOL2019 into the Filter field located above the New Digital Assistant tile.

By importing the ODA_HOL2019 DA, you have added a digital assistant and two skills to your instance:

  • ODA_HOL_2019 (digital assistant)
  • RetailBot (skill)
  • FinancialBot (skill)

You are now ready for the main part of the lab. Skip ahead to the Design the Pizza Skill section.

Option B: Use the Shared Instance

This section only applies if you are at an Oracle event with a shared instance of Digital Assistant.

Log In to the Shared Instance

  1. In your browser, enter the URL that has been provided by your lab instructor.
  2. Log in to the instance using the credentials that you have been provided.

After successfully logging in, you will land on the ODA home page.

Clone Copies of the Starter Skill and Digital Assistant

In this lab, a starter skill and a starter digital assistant are provided for you. Before you get to work, you need to create your own copies.

Clone the Starter Skill

  1. With the Oracle Digital Assistant UI open in your browser, click main menu icon to open the side menu.
  2. Click Development and select Skills.
  3. Click main menu icon again to collapse the side menu.
  4. In the skills dashboard, find the tile for PizzaSkill.
  5. Click PizzaSkill's Options menu (menu icon) and select Clone.
    screenshot showing the Skills page in ODA. There is a tile for New Skill and a tile for PizzaSkill. Within the tile for PizzaSkill, the Options menu is selected, and it shows menu items for Edit, New Version, Clone, etc.
  6. In the Create Clone dialog, enter a value for Display Name using the form <your_initials>_PizzaSkill.

    For example, if your initials are AB, you'd name the skill AB_PizzaSkill.

  7. Click Clone.
  8. On the Skills dashboard page, select <your_initials>_PizzaSkill to open it up in the designer.

Clone the Starter Digital Assistant

  1. Click main menu icon to open the side menu.
  2. Click Development and select Digital Assistants.
  3. Click main menu icon again to collapse the side menu.
  4. In the skills dashboard, find the tile for ODA_HOL2019, open its Options menu (menu icon), and select Clone.
  5. In the Create Clone dialog, enter a value for Display Name using the form <your_initials>_ODA_HOL2019.

    For example, if your initials are AB, you'd name the skill AB_ODA_HOL2019.

  6. Click Clone.
  7. On the Digital Assistants dashboard page, select <your_initials>_ODA_HOL2019 to open it up in the designer.

Design the Pizza Skill

In this part of the lab, we'll complete development of the Pizza Skill that has been started for us. After familiarizing ourselves with the starter skill, we'll:

  • Create a composite bag entity to consolidate existing entities which represent the different variable elements of the pizza (size, topping, delivery time etc) and make it easier to manage entities from the dialog flow.
  • Add logic to the skill's dialog flow to manage the pizza ordering process.
  • Train and test the skill.
  • Publish the skill so that it can be used in a digital assistant.

Explore and Test the Skill

The conversational AI use case you are working with is a skill for ordering pizza. To familiarize yourself with the designer and the skill itself, try it out by following these steps:

  1. In ODA, click main menu icon to open the side menu.
  2. Click Development and select Skills.
  3. Click main menu icon again to collapse the side menu.
  4. In the skills dashboard, select your copy of PizzaSkill.
  5. In the left navigation for the designer, select the Intents icon.
  6. Click the OrderPizza intent and quickly scan the utterances.
  7. In the left navigation for the designer, select the Entities icon.
  8. Select the PizzaDough entity and look at the way that it is configured.
  9. Repeat the above step for PizzaSize and PizzaTopping.
  10. Locate the Train button (Train bot icon) on the right side of the page, click it, click Submit, and then wait a few seconds for the training to complete.
  11. Find the Bot Tester icon (the Bot Tester icon) on the top of the page and click it.
  12. In the tester's Message field, type I want to order pizza, click Send, and note the skill's response.

    For now it's just a static response. It will become more dynamic once we add logic to the dialog flow.

  13. Click the Reset button at the top of the tester window and then close the tester.

Add a Composite Bag Entity

When a customer orders a pizza, details such as toppings, size, and crust need to be specified. In PizzaSkill, each of these variables is represented by an entity.

The challenge for any chatbot is that the user can include varying subsets of the required information in their initial input. For example, one person might specify the size and topping, but not the type of crust. And another person might specify only the crust. In each case, the skill should recognize any entities supplied in the original input, and prompt for those that are not.

In this step, we’ll create a composite bag entity, which is a special entity that automatically recognizes and prompts for the appropriate entities for a pizza order. In addition to our custom entities (PizzaSize, PizzaTopping, PizzaDough), we'll include a system entity for DeliveryTime.

Create the Composite Bag Entity:

  1. Select the Entities icon and click the Add Entity button to create a new entity.
  2. In the Name field, change the value to PizzaBag.
  3. In the Configuration section, in the Type dropdown, select Composite Bag.
    Screenshot showing the Configuration section of the page for the PizzaBag entity. The Type dropdown menu is opened, showing options for Derived, Value List, Entity List, Regular Expression, and Composite Bag.

Add Bag Items for the PizzaSize, PizzaTopping, PizzaDough, and DeliveryTime Entities

  1. Click Add Bag Item button.
  2. On the Add Bag Item page, fill in the following values:
    • Name: PizzaSize
    • Type: Entity
    • Entity Name: PizzaSize (If prompted in a popup, select Overwrite.)
    • Maximum User Input Attempts: 4
    • Error Message: Sorry, '${system.entityToResolve.value.userInput!'this'}' is not a valid size of pizza.
  3. Click Add Prompt button.
  4. For the value, enter What size of pizza would you like?
  5. Again, click Add Prompt button.
  6. For the value, enter Please choose small, medium or large.
  7. Click Close.
  8. Again, click Add Bag Item button.
  9. On the Add Bag Item page, fill in the following values:
    • Name: PizzaTopping
    • Type: Entity
    • Entity Name: PizzaTopping (If prompted in a popup, select Overwrite.)
    • Error Message: Sorry, we don't have that topping
    • Prompt for Disambiguation: switched ON
    • Disambiguation Prompt: Sorry you can only order one topping type
  10. Click Close.
  11. Again click Add Bag Item button.
  12. On the Add Bag Item page, fill in the following values:
    • Name: PizzaDough
    • Type: Entity
    • Entity Name: PizzaDough
    • Prompt for Value: false
  13. Click Close.
  14. For the fourth (and final) time, click Add Bag Item button.
  15. On the Add Bag Item page, fill in the following values:
    • Name: DeliveryTime
    • Type: Entity
    • Entity Name: TIME
    • Maximum User Input Attempts: 4
  16. Scroll down to the Prompts section, replace the existing prompt with When can we deliver that for you?, and press Enter.
  17. Click Add Validation Rule button.
  18. In the Expression field, enter ${(pizza.value.DeliveryTime.hrs?number < 10)?then('true','false')}
  19. In the Error Message field, enter Sorry, we only deliver up to 9:30pm and press the Enter key.
  20. Click Close.

Here is what the PizzaBag composite bag should look like in the designer:

Screenshot showing the Entities page in the designer. On the left side of the page is a list of entities, including PizzaBag, PizzaDough, PizzaSize, and PizzaTopping. The PizzaBag entity is selected. On the right side of the page, are the Description and Configuration sections. Within the Configuration section, the value of the Type field is Composite Bag, and the Bag Items sub-section contains items for PizzaSize, PizzaTopping, PizzaDough, and DeliveryTime.

Associate the Entity with the Intent

Now we need to associate the PizzaBag composite entity to the OrderPizza intent so that we can extract the key words and phrases from the user input.

  1. Select the Intents icon.
  2. Select the OrderPizza intent.
  3. Click the Add entry dropdown button button and select PizzaBag from the dropdown. See this screenshot to help locate the button:
    A screenshot showing a part of the Intents page. On the top right of the screenshot is an <b>Intent Entities</b> label and dropdown for entities that you can add to the intent.

Implement the Pizza Ordering Logic

Next we need to write logic for the skill to understand the user query and respond accordingly. We'll do this in the dialog flow where we can choreograph the interaction between the skill and its users.

  1. Click Dialog Flow icon.
  2. Within the context variables section, add this entry: pizza: "PizzaBag"

    Here's how the addition should look in context.

    context:
      variables:
        iResult: "nlpresult"
        pizza: "PizzaBag"

    Important: For all dialog flow examples, make sure that you get the indentation exactly right. Each state starts with two spaces of indentation. With each additional level of indentation, you add two more spaces.

  3. Update the text and transitions properties in the startOrderPizza state:
      startOrderPizza:
        component: "System.Output"
        properties:
          text: "ok lets get that order sorted"
          keepTurn: true
        transitions:
          next: "resolveEntities"
  4. Click Copy in the following code box and then paste the copied code below the startOrderPizza state:
      resolveEntities:
        component: "System.ResolveEntities"
        properties:
          variable: "pizza"
          nlpResultVariable: "iResult"      
          maxPrompts: 3
          cancelPolicy: "immediate"        
        transitions:
          next: "setPizzaDough"
          actions:
            cancel: "maxError"
    
      setPizzaDough:
        component: "System.SetVariable"
        properties:
          variable: "pizza.PizzaDough"
          # value set for the variable.
          value: "${pizza.value.PizzaDough?has_content?then(pizza.value.PizzaDough,'regular')}"
        transitions:
          next: "showPizzaOrder"
    
      showPizzaOrder:
        component: "System.Output"
        properties:
          text: "Ok so we are getting you a ${pizza.value.PizzaSize} ${pizza.value.PizzaTopping} at ${pizza.value.DeliveryTime.date?long?number_to_time?string('HH:mm')}.  This will be on our ${pizza.value.PizzaDough} base "
        transitions: 
          return : "showPizzaOrder"
    
      maxError:
        component: "System.Output"
        properties:
          text: "OK lets connect you with someone to help"
        transitions:
          return: "maxError"

Notes on What We Just Did

  • We have added a context variable pizza of type PizzaBag and used it in the resolveEntities state. This state is called when the OrderPizza intent is resolved.
  • The resolveEntities state calls a system component (System.ResolveEntities), iterates through all the entity fields in the composite bag, converses with the user, and resolves all the fields.
  • The setPizzaDough state checks if the dough value is null. If yes, then it sets it to regular.
  • Once all the entities are resolved, we output the pizza details in the showPizzaOrder state.
  • The maxError state is called if the number of attempts for an entity in the bag has reached the value of maxPrompts.

Validate and Train PizzaSkill

  1. Click the Validate button to validate the skill.

    (The Validate button is in the top navigation.)

  2. If validation fails, delete the code in the dialog flow, replace it with the contents of the PizzaSkill_BotML.txt file, and validate the flow again.
  3. Click Train bot icon, click Submit, and then wait a few seconds for the training to complete.

Test PizzaSkill

  1. Find the Bot Tester icon (the Bot Tester icon) on the top of the page and click it.
  2. Type I want to order a medium pizza in the Message field and click Send.
  3. Click the Intent/QnA tab and observe the Entity Matches section.

    You'll notice that the PizzaSize value is set to Medium:

    Screenshot of the skill tester. On the left side, there is a conversation between the user and the skill. On the right side, the Intent/Q&A tab is selected, there is a graph showing the OrderPizza intent having a match of 100%, and there are entity matches shown for PizzaSize and PizzaBag. For PizzaBag, it shows Value:Medium.
  4. Click the Reset button.
  5. Now try Can I place an order for a medium meaty pizza to be delivered at 9:00 PM and observe the response:
    Screenshot of the skill tester. On the left side, there is a conversation between the user and the skill. The response to the user is 'ok let's get that order sorted' and 'Ok, so we're getting you a Medium Meaty at 21:00. This will be on our regular base.' On the right side, the Conversation tab is selected, and there is a flow chart showing the sequence of states called: startOrderPizza, resolvedEntities, setPizzaDough, and showPizzaOrder.
  6. Click Reset.
  7. Now let’s try one with a gluten-free base by typing: A small veggie pizza to be delivered at 8:00pm, also can you please make it gluten-free?
    Screenshot of the skill tester. On the left side, there is a conversation between the user and the skill. The response to the user is 'ok let's get that order sorted' and 'Ok, so we're getting you a Small Veggie at 20:00. This will be on our gluten free base.'
  8. Click Reset.
  9. Now try Can I place an order for a medium meaty pizza to be delivered at 10:00 PM.

    This should result in the following response:

    Screenshot of the skill tester. On the left side, there is a conversation between the user and the skill. The response to the user is 'ok let's get that order sorted' and 'Sorry, we only deliver up to 9:30 PM.' On the right side, the Conversation tab is selected, and there is a flow chart showing the sequence of states called: startOrderPizza and  resolvedEntities.

  10. Click Reset.
  11. Now try Can I place an order for a small medium meaty pizza to be delivered at 9:00 PM and see what you get.
  12. Click Reset.
  13. Now try Can I place an order for a small sausage pizza to be delivered at 9:00 PM and see what you get.
  14. Click Reset.
  15. Next try I want a small meaty pizza.

    The skill asks at what time to deliver the pizza.

  16. To see how the skill reacts when the user changes his mind mid-stream, type actually make it large and press Enter.
  17. When the skill repeats the question about delivery time, type 9:00 PM.

    This is what the conversation should look like:

    Screenshot of the skill tester. On the left side, there is a conversation between the user and the skill. After the user has entered '9:00pm', the response from the skill is 'OK so we are getting you a Large Meaty at 21:00. This will be on our regular base.'

    As you can see, the skill was able to incorporate the change in the order and continue without missing a beat.

Using the composite entity, we are able to resolve all the entities in a single customer query!

Publish the Skill

Now that we are done building the skill, we'd like to add it to our digital assistant.

However, to make the skill available to be added to a digital assistant, we first need to publish it:

  1. Click main menu icon to open the side menu.
  2. Click Development and select Skills.
  3. Click main menu icon again to collapse the side menu.
  4. In the skills dashboard, find the tile for your copy of PizzaSkill.
  5. Click the skill's Options menu (menu icon) and select Publish.
    Screenshot showing the PizzaSkill tile with the Options menu opened, and 8 menu items displayed, of which Publish is the 4th
  6. On the Publish Skills page, click Publish.

    Once you have published the skill, the 'Published' badge badge should appear on the skill's tile.

    This also means that you can no longer make any changes to this version of the skill.

Congrats! Your skill is now ready to be added to a digital assistant!

Set Up the Shopping Centre Digital Assistant

Digital assistants are virtual personal assistants that users can interact with using natural language. When a user engages with the digital assistant, the digital assistant evaluates the user input and routes the conversation to the appropriate skill.

Among other things, the digital assistant:

  • Greets the user upon access.
  • Upon user request, lists what it can do and provides entry points into the given skills.
  • Routes explicit user requests to the appropriate skill.
  • Handles interruptions to flows.
  • Handles disambiguation.
  • Handles requests to exit the bot.

Explore the Digital Assistant

The starter digital assistant (or, DA for short) that you just cloned consists of two skills – FinancialBot and RetailBot. Later, we'll add PizzaSkill to the DA.

To familiarize yourself with the DA, try it out by following these steps:

  1. Click main menu icon to open the side menu.
  2. Click Development and select Digital Assistants.
  3. Click main menu icon again to collapse the side menu.
  4. On the Digital Assistants dashboard, find the tile for your copy of ODA_HOL2019 and select it to open it up in the designer.
  5. Ensure the Skills icon is selected (the Skills icon).

    Notice that FinancialBot and RetailBot are listed there.

  6. Select the RetailBot skill and browse the attributes of its description and interaction model.
  7. Select the FinancialBot skill and browse the attributes of its description and interaction model.
  8. Select the Intents icon.
  9. Note the three intents.

    These are built in to all digital assistants. Here's what they are for:

    • exit: applies when the user signals the desire to exit the current conversation or context in the digital assistant.
    • help: applies when the user asks for help or orientation.
    • unresolvedIntent: applies to user input that doesn't match well with the exit and help intents.
  10. Click the Settings icon and select the Configurations tab.

    Notice the Routing Parameters, Conversation Parameters and Other Parameters sections.

  11. Click Train bot icon, click Submit, and then wait a few seconds for the training to complete.
  12. Find the tester icon (the Digital Assistant Tester icon) on the top of the page and click it.
  13. In the tester's Message field, type help me, press Enter, and note the DA's greeting and initial menu.
  14. Click the Reset button.
  15. Now try entering Do I have enough money in my savings account, pressing Enter, and observing the response.
  16. Close the tester.

Add PizzaSkill to the DA

With a new pizzeria opening in the shopping centre, we want the digital assistant to support this merchant as well. So let's add the PizzaSkill to our digital assistant and then train the digital assistant so that it can work with the new skill:

  1. In your DA, select the Skills icon.
  2. Click Add Skill button.
  3. Find the tile for your copy of PizzaSkill.

    Note: The skill won't appear there if you haven't completed the Publish the Skill part of the lab.

  4. In the tile for your skill, click Add Skill icon.
  5. Click Close to close the Skill Catalog.
  6. Click Train bot icon, click Submit, and then wait a few seconds for the training to complete.

Personalize Your Digital Assistant

Once you have created a digital assistant and added skills to it, you can customize some of the aspects of the digital assistant, such as the invocation name of the digital assistant’s skills and the language in the digital assistant’s help and exit intents.

Change the Invocation Name

An important part of configuring any skill is coming up with a good invocation name, which is used in explicit invocation of the skill. Here are the steps to change the invocation name of recently added skill:

  1. In your DA, select the Skills icon.
  2. Select Pizza Skill.
  3. Scroll down to the Interaction Model section of the page and change the Invocation Name to Pizza King.
  4. Change the example utterance to Order Pizza.

Test the Invocation Name

Now let’s try various invocation patterns and see whether and how the digital assistant responds:

  1. Click the tester icon (the Digital Assistant Tester icon).
  2. In the tester's Message field, type Go to Pizza King to place my pizza order, press Enter, and note the DA's response.
  3. Click the Reset button.
  4. Now try Pizza King.
  5. Click Reset.
  6. Now try Pizza King to check my order.
  7. Click Reset.
  8. Now try I want a large meaty pizza from pizza king.
  9. Click Reset.
  10. Now try Can you use Pizza King to place an order.
  11. Click Reset.

System Intents and Prompts

You can customize the built-in system intents and the prompts that are driven by them.

First, let's add some utterances to the built-in help intent:

  1. In your DA, select the Intents icon.
  2. Select the help intent.
  3. In the Examples section, add the following utterances:
    • Can someone help me
    • What can you do
    • What things do you do
    • What can I ask you

The digital assistant comes with configurable prompts to respond to various types of user input. These prompts can be modified in the DA's configuration settings.

Let's modify the DA's help prompt:

  1. In the DA, click the Settings icon and select the Configurations tab.
  2. Scroll down to the Conversation Parameters section of the page.
  3. Modify the value of Digital Assistants Help Prompt to Welcome! I can do following things for you:
  4. Click Train bot icon, click Submit, and then wait a few seconds for the training to complete.

Test the Utterances and Modified Prompt

To see the new utterances and prompt in action:

  1. Click the tester icon (the Digital Assistant Tester icon).
  2. In the tester's Message field, type Can someone help me, press Enter, and note the DA's response.

Evaluate Routing Behaviors

Before putting the digital assistant into production, let’s use the tester to evaluate various aspects of its routing behavior.

  • Open the tester by clicking the tester icon (the Digital Assistant Tester icon).

No Match

  1. In the tester's Message field, type I want a burger and press Enter.

    Since no match is found in the DA and skill, it generates the DA-level help card:

    Screenshot showing the digital assistant tester. After the user input ('I want a burger') is the DA's response (The text 'No matches were found. Here are some things you can do.' followed by a card for Pizza King with the 'Order Pizza' option.)

    Note: Only the Pizza King shows in the screenshot, but you can use the horizontal scroll arrows to see the cards for the other skills.

  2. Click Reset.

Implicit Invocation

  1. In the tester's Message field, type Send money and press Enter.

    Notice that the routing resolves to the Digital Bank candidate skill and its Send Money intent:

    Screenshot showing the digital assistant tester. After the user input ('Send money') is the DA's response (The text 'From which account do you want to make a payment' followed by options for savings, checking, and credit card.)

    Note: "Digital Bank" is the invocation name of FinancialBot.

  2. Click the Routing tab and scroll down.

    Notice the intent evaluation that leads to this response:

    Screenshot showing the Intent Calls section of the Routing tab of the DA tester. In the Candidate Skills row , the Digital Bank skill is circled. In the Candidate Flows row, the Send Money intent is circled.
  3. Click Reset.

Note: In these examples, you might get slightly different results than what are shown here, especially in the confidences scores (given in percentages) when resolving intents. And in some cases, the resolved intents could vary, should the differing confidence scores push those intents above or below the given confidence thresholds. The cause of this variance is the non-deterministic nature of the AI behind the natural language processing and the fact that these bots have a limited number of training utterances (in order to make the lab simpler).

Explicit Invocation

  1. In the tester's Message field, type I want to send money from Digital Bank and press Enter.

    Here’s the user’s input and the digital assistant’s initial response:

    Screenshot showing the digital assistant tester. After the user input ('I want to send money from Digital Bank') is the DA's response (The text 'From which account do you want to make a payment' followed by options for savings, checking, and credit card.)
  2. Click the Routing tab and scroll down to the Rules section and notice the rule that is displayed.
    Screenshot showing the Rules section of the Routing tab of the DA tester. The rule displayed reads 'Explicit invocation takes precedence over other flows in digital assistant context.'

    In the Intent Calls section, you can see that the Digital Bank skill gets a much higher confidence score than the other skills.

    Screenshot showing the Intent Calls section of the Routing tab of the DA tester. In the Candidate Skills row , the Digital Bank skill is circled. In the Candidate Flows row, the Send Money intent is circled.
  3. Click Reset.

Ambiguous Utterance

  1. In the tester's Message field, type What is my balance? and press Enter.

    Here’s the conversation:

    Screenshot showing the digital assistant tester. After the user input ('What is my balance?') is the DA's response (The text 'Do you want to go to:' followed by options for GiftCardBalance in Sport Store, Balances in Digital Bank, and None of the above.)

    As you can see, the digital assistant is unsure of what the user wants to do, so it provides a prompt asking the user to choose among the Sport Store (which is the invocation name for the RetailBot skill) and Digital Bank skill intents.

  2. Click the Routing tab and scroll down.

    Notice the evaluation in the Intent Calls section that leads to this response:

    Screenshot showing the Intent Calls section of the Routing tab of the DA tester. The significant details are described in the ensuing text.

    Both the candidate skills got high scores (100%). And then for each of those skills, the router identified a candidate flow that also scored highly (also 100%).

    Since the GiftCardBalance and Balances candidate flows exceed the confidence threshold, and since difference between their scores is less than the Confidence Win Margin value (10%), the digital assistant asks the user to choose between those intents.

  3. Click Reset.

Context Awareness

  1. In the tester, type What is my balance? and press Enter.

    Here’s the conversation:

    Screenshot showing the digital assistant tester. After the user input ('What is my balance?') is the DA's response (The text 'Do you want to go to:' followed by options for GiftCardBalance in Sport Store, Balances in Digital Bank, and None of the above.)
  2. Select Balances in Digital Bank.
    Screenshot showing the digital assistant tester. After the user input ('Balances in Digital Bank') is the DA's response (The text 'For which account do you want your balance' followed by options for savings, checking, and credit card.)
  3. Select checking.
    Screenshot showing the digital assistant tester. After the user input ('checking') is the DA's response ('The balance in your checking account (903423-123) is $2334.56')
    .
  4. Again, type How much do I have in my savings?

    Here is the response:

    Screenshot showing the digital assistant tester. After the user input ('How much do I have in my savings') is the DA's response ('The balance in your savings account (258293-832) is $2610.56')
    .
  5. Click Reset.

Notes on What We Just Did

As you can see, the user starts with the question "What is my balance?", goes through a prompt to disambiguate between the Digital Bank skill and the Sport Store skill, and eventually gets her checking account balance. Then the user enters "What is my balance?" again, but this time doesn't have to navigate through any disambiguation prompts. The info in the Routing tab helps to explain why.

Also note that in the Rules section of the Routing tab, you see the following:

Screenshot of the Rules section of the Routing tab. It shows the detail 'Current context matches with very high confidence. Other skill flows are ignored.'

So, even though there are matching intents from the Sport Store skill, they are ignored. The Intent Calls section shows all of the matching intents, but the entry for “Current Context”, which contains only the Digital Bank skill’s Balances intent, is decisive.

Screenshot showing the Intent Calls section of the Routing tab of the DA tester. For Candidate Skills, Digital Bank and Sports Store match. For Current Context, Digital Bank's Balances intent matches. For Candidate Flows, Digital Bank's Balances intent matches.

Non sequitur

Non sequitur refers to interrupting a conversation flow by changing the subject. Here's an example where such interruptions occur because the user needs info from one skill to complete the flow in another skill.

  1. In the tester, type I want to order a small meaty pizza and press Enter.

    Pizza Skill is invoked and here is the response:

    Screenshot showing the digital assistant tester. After the user input ('I want to order a small meaty pizza') is the DA's response ('ok lets get that order sorted' followed by 'When can we deliver that for you?')
  2. To simulate the user suddenly being unsure if he has enough money, type the following: oh, do I have enough money on my credit card?

    At this point the DA detects that the intent corresponds to the Digital Bank skill and asks if user wants to switch to Balances in Digital Bank:

    Screenshot showing the digital assistant tester. After the user input ('oh, do I have enough money on my credit card?') is the DA's response ('Do you want to switch to Balances in Digital Bank now' followed by Yes and No options.

  3. Select Yes.
     Screenshot showing the digital assistant tester. After the user input ('Yes') is the DA's response ('The balance in your credit card account (4352-3423-1234-5239) is $-208.88' followed by 'Your remaining credit is $4791.12' followed by 'Do you want to resume OrderPizza in Pizza King now?' followed by Yes and No options.

    The user is presented with his financial details, thus completing that flow. At that point, the DA asks if it can return back to PizzaSkill.

  4. Again, select Yes.
    Screenshot showing the digital assistant tester. After the user input ('Yes') is the DA's response ('When can we deliver that for you')

    The DA returns to PizzaSkill and resumes the conversation where you left it:

  5. Type 9:00 PM and press Enter.
    Screenshot showing the digital assistant tester. After the user input ('9:00 PM') is the DA's response ('Ok so we are getting you a Small Meaty at 21:00. This will be on our regular base')

In this sequence, you started ordering a pizza, confirmed you had enough money in your account, and finished ordering the pizza.

Non sequitur – Complex Conversation

Let’s try a more complex conversation:

  1. In the tester, type I want to order a large pizza at 9:00 PM today and press Enter.
  2. Instead of selecting the kind of pizza, type oh, do I have enough money?

    At this point, the DA will ask you to switch to Balance in Digital Bank.

  3. Select Yes.
  4. Now, instead of selecting the account type, type how about my gift card balance?

    The DA asks if you want to switch to GiftCardBalance in Sport Store.

  5. Select Yes.
  6. Type GC100 as the gift card number and press Enter.

    The DA informs you of your gift card balance.

    Then the DA asks if you want to return to Balance in Digital Bank.

  7. Select Yes.
  8. Select savings as your account type.

    The DA fetches the savings account details for you and asks if you want to return to OrderPizza in Pizza King.

  9. Select Yes.
  10. Select any of the options for the kind of pizza you want to order.
  11. Observe the states flow in the Conversation tab.
    Screenshot showing the Conversation tab of the digital assistant tester. Through a flow chart it depicts the states invoked in the DA in the following order: startOrderPizza, resolveEntities, startBalances (switch to Financial Bot), askBalancesAccountType, startGiftCardBalance (switch to RetailBot), setPizzaDough (switch to PizzaSkill), and showPizzaOrder.

You are now done with creating, personalizing, and evaluating the routing behavior of your digital assistant! In the next section, we'll add it to a web channel through which users can access it.

Expose the Digital Assistant to Users through a Web Channel

In this section of the lab, we'll publish our DA through a web channel, create a web application to expose the DA to users, and test the DA from a web page.

Note: If you are using a version of Oracle Digital Assistant that is based on Oracle Cloud Infrastructure Gen 1 (such as releases 19.1.5 and 19.4.1), this section of the tutorial won't work for you. The version of the SDK that this section requires is only available for instances of Digital Assistant that have been provisioned on Oracle Cloud Infrastructure Gen 2 (including versions 19.12 and later). To set a web channel on a Gen 1 instance of Digital Assistant, see Expose Your Digital Assistant through a Web Channel.

Create a New Channel

  1. Click main menu icon to open the side menu.
  2. Click Development and select Channels.
  3. Click main menu icon again to collapse the side menu.
  4. On the Users tab, click + Channel.
    Screenshot showing a small section of the Channels page. The Users tab is selected. The Add Channel button is the first item in the tab.
  5. In the Create Channel dialog, fill in the following fields:
    • Name: A unique name for the channel, such as PK_Web_ShoppingCentre.

      Important: If you are using the shared instance for this lab, be sure to include your initials in this field to distinguish it from the channels of other lab participants.

    • Channel Type: Oracle Web
    • Allowed Domains: * (asterisk)
    • Client Authentication Enabled: Switch to Off
  6. Click Create.
  7. If you are not returned to the page for the newly-created channel, enter part of your channel name in the Filter field, and then select your channel.

    Screenshot of the Channels page with none of the fields filled in. The Route To field is the first field in the list of fields.
  8. Open the Route To dropdown menu, enter your DA name in the Filter box, and select your DA.
  9. Switch Channel Enabled to ON.
    Screenshot of part of the Channels page showing the Route To field with a digital assistant selected and the Channel Enabled field set to ON.
  10. Copy the the value of the Channel Id field to a text file.

    You will use it later on this lab while running the sample client application.

Set Up a Web Page

To create the web page from which users can access the DA:

  1. Create a folder called chat-page.
  2. Download chat-page.zip into the folder, and then unzip it.

    Your folder should now contain index.html and the css, images, and scripts subfolders.

  3. Copy native-client-sdk-js/web-sdk.js from your Oracle Web SDK folder and put it in the scripts subfolder.

Add a Chat Widget to the Web Page

Now we'll add the chat widget to the web page:

  1. In the top folder (chat-page), open index.html in an editor.
  2. Click Copy in the following code box to copy the code, and then insert the copied code below the <link rel="stylesheet" href="css/style.css"> tag.
        <script>
            var chatWidgetSettings = {
                URI: '<put-your-URI-here>',
                channelId: '<put-your-channel-ID-here>'
            };
            function initSdk(name) {
                // Default name is Bots
                if (!name) {
                    name = 'Bots';
                }
                setTimeout(() => {
                    const Bots = new WebSDK(chatWidgetSettings); // Initiate library with configuration
                    Bots.connect()                               // Connect to server
                        .then(() => {
                            console.log("Connection Successful");
                        })
                        .catch((reason) => {
                            console.log("Connection failed");
                            console.log(reason);
                        });
                    window[name] = Bots;
                });
            }
        </script>
        <script src="scripts/web-sdk.js" onload="initSdk('Bots')">
        </script>
  3. Set these chatWidgetSettings properties:

    • URI: This is the host and domain name for your Oracle Digital Assistant instance. For example: xxxx.xxx.digitalassistant.xxx.xxx.com.

      You can get this URI from the address bar of your browser when it is displaying your Digital Assistant instance.

      Screenshot of a browser address bar, showing a URL that begins with oda- and ends with data.digitalassistant.oci.oc-test.com

      Note: Don't include https://.

    • ChannelId: This is the channel ID that you noted when you created the Oracle Web channel. For example: 12a45b92-2c85-88aa-810d-1dc0d1cfe472.
  4. Save your changes.

Notice that the last <script> element references the web-sdk.js file, which contains functions that enable you to programmatically send messages.

Test the DA on the Web Channel

Let's try out the chat widget.

  1. On your system, navigate to the chat-page folder and double-click index.html to open the page in a web browser.

    You should see a web page with the chat widget's icon on the bottom of the page.

    Chat widget
  2. Click the widget.
  3. Start communicating with the DA by asking for help and/or making specific requests, such as ordering pizza and checking account balances.
    A screenshot of a chat window showing a conversation starting with 'What can you do for me?' and continuing with a welcome message and a menu of options provided by the Digital Bank.

    Note: There are menus for all three skills, which you can scroll through by using the arrows on the sides of the menus.

    A screenshot of a chat window showing a conversation starting with 'What can you do for me?' and continuing with a welcome message and a menu of options provided by the Digital Bank.

That's it! You have now introduced your DA to its public by hooking it up to a web interface.