Subscribe

Share

Application Development

Escape Room

How to unlock users who get stuck in a chatbot conversation

By Frank Nimphius

March/April 2019

Building good chatbots is a mixture of art and technology. The art of developing chatbots lies in the conversation design, which is usually not what software developers have been trained to do.

It is human nature that conversations are not typically straightforward. Topics may change in the middle of an interaction or, if we don’t understand a question, we may ask for clarification.

Though the human brain is far from being a fast supercomputer, which is able to analyze millions of records in fractions of a second, it is a real genius when it comes to understanding context and putting together 1 + 1 to become 2, even if parts of the information are missing.

Because artificial intelligence is not yet on the level of human intelligence, chatbots need good conversational design to ensure that context changes are handled and human users are safely guided through a conversation.

If your conversation design cannot prevent users from getting stuck in a bot conversation, the least it can do is to show users a way to free themselves from being locked in.

This article discusses techniques you can use in Oracle Digital Assistant to guide users in situations where they don’t know how to proceed with a conversation or change the topic.

About the Sample

Oracle Digital Assistant is the next generation of the Oracle chatbot platform. It manages and coordinates multiple smaller-scoped skills in a composite chatbot solution that assists users in completing multitask conversations.

The use case for the hands-on exercise in this article is a simplified version of a pizza ordering bot. You don’t build the complete digital assistant solution but the skill only, for which a starter bot is provided.

Getting Ready

Below are the prerequisites for following along with the hands-on steps in this article:

Follow these initial hands-on steps to start the service and import, train, and test the bot.

  1. Start Oracle Digital Assistant in a browser by typing https://<your cloud URL>/botsui/ into the URL field.
  2. Click the hamburger icon () at the upper left.
  3. Choose Development and then Skills.
  4. Close the menu by clicking the hamburger icon ().
  5. Click the Import Skill button at the upper right.
  6. Navigate to the downloaded and extracted resources for this article and navigate to the starter folder.
  7. Select the OraclePizza2019(1.0).zip starter bot file, and click Open.
  8. Click the Oracle Pizza 2019 tile in the Skills dashboard to open the skill bot.
    Note: If you don’t see the imported bot because other bots fill your screen, type Oracle into the Filter field above the + New Skill tile.
  9. Train the bot by clicking the  link in the upper right.
  10. In the opened dialog box, accept the default settings and click Submit.
  11. Click  in the upper right.
    Note: Instant Apps should open in a separate tab. If no tab opens, ensure that the pop-up is not blocked and try again.
  12. In the opened tab, click the Add Instant App tile ().
  13. Click the Import tile ().
  14. Click the Upload a Schema File link.
  15. Navigate to the downloaded and extracted resources for this article, and navigate to the starter folder.
  16. Select the OraclePizzaHelp.json file, and click Open.
  17. Click the Instant App Info button () in the upper left and notice that the API ID value is oraclepizzahelp.
  18. Close the Instant Apps browser tab.

What you just did: By importing the OraclePizza2019(1.0).zip file, you installed and then trained the pizza bot sample skill. You are going to use the imported Instant Apps web form later in the hands-on exercise.

Experiencing the Problem

Before you fix the imported skill’s conversation issue, first experience the problem from a user perspective.

  1. Run the sample bot in the embedded conversation tester by clicking the Skill Tester icon () in the left menu.
  2. Type I like to order pizza into the Message field and press the Enter key on your keyboard.
  3. Type salami into the Message field and press the Enter key again.
  4. Apparently salami is not a valid answer. Type ham into the Message field and press the Enter key.
  5. Oracle is an American company, so type bbq into the Message field and press the Enter key.
  6. Again, this is not a valid choice. Click the Reset button () at the top right.
  7. Close the conversation tester by clicking the Close icon (X), located next to the Reset button.

What happened: The pizza skill validates the pizza type selection against a value- list entity. The entity contains values and synonyms for the pizzas that a user can order. When you input a wrong pizza type, the entity validation fails and the prompt is displayed again. The implementation in the sample keeps you in an infinite validation loop with no exit. So the first thing you need to do to improve the user experience is to implement an exit strategy.

Exiting the Validation Loop

Input components in Oracle Digital Assistant have two properties in common:

  • maxPrompts expects a numeric value that defines the number of allowed failed user inputs before a cancel transition.
  • variable references a dialog flow context variable that is updated with the user input. If the context variable is of an entity type (for example, PizzaType), the variable gets validated against the entity when the user provides a value.

To escape the validation loop, all you need to do is define a maxPrompts property value and configure the cancel action transition.

  1. Open the dialog flow builder by clicking the Flows icon () in the left menu.
  2. Navigate to the askPizzaType state and set the value of the maxPrompts property to 2. The resulting line should look like this: maxPrompts: 2.
  3. Put your cursor into line 42. Use the space bar on your keyboard to vertically align the cursor with the beginning of the next element.
  4. Type actions: and press the Enter key.
  5. Position the cursor to vertically align below the actions: element you just added. Again, use the space bar on your keyboard to do this.
  6. When the cursor is vertically aligned, press the space bar two more times, so the cursor is indented by two characters.
  7. Type cancel: "cancelPizzaOrder" (with the quotation marks). The transitions: element should look like it does in Figure 1.

    chatbots figure 1 Transitions element with cancel action

    Figure 1: Transitions element with cancel action

  8. Repeat the testing steps 19–22.
  9. Notice that you are no longer stuck in a validation loop. You are free, and you could give the pizza ordering another try.
  10. Click the Reset button () at the top right.
  11. Close the conversation tester by clicking the Close icon (X), located next to the Reset button.

What you just did: In this part of the hands-on exercise, you interrupted the validation loop by setting the maxPrompts parameter and defining a cancel transition that handles the invalid user input when the value set for maxPrompts is exceeded. Still, the user experience is not great.

Note: Instead of canceling the pizza order, you could have navigated the request to a state that provides detailed help. This exercise will eventually do that, so please bear with me for the moment.

Provide Visual Help

In this part of the hands-on tutorial, you are going to display a list of values instead of only displaying an input prompt to the user. After all, good user guidance is a great recipe for a positive user experience.

  1. Go to line 39 of the dialog flow builder and edit the component definition as shown in Figure 2. The highlighted parts are the new configuration information to add.

    chatbots figure 2 Adding a list of actions to the pizza type prompt

    Figure 2: Adding a list of actions to the pizza type prompt

  2. Run the sample bot in the embedded conversation tester by clicking the Skill Tester icon () in the left menu.
  3. Type I like to order pizza into the Message field and press the Enter key.
  4. A list of pizza types is displayed for the user to select from. However, you insist on ordering a salami pizza. Type salami into the Message field and press the Enter key.
  5. The list of values is displayed again. Next type bbq into the Message field and press the Enter key.
  6. Again, as before, the pizza order is canceled. Click the Reset button () at the top right.
  7. Close the conversation tester by clicking the Close icon (X), located next to the Reset button.

What you just did: In this part of the hands-on instructions, you improved the user experience by providing good guidance on the choices of pizza. Still, if users insist on a pizza type that is not in the menu, the behavior of the bot is not such that it provides sufficient information. For example, the System.CommonResponse component that is used in the askPizzaType state supports page ranging to display a reduced list of values when the potential list of values is too long to display without requiring users to scroll. In this case, the user assumption that salami is a valid pizza type may appear to be correct. So you need to provide a bit more guidance in the prompts, which is what you will do next.

Note: Selecting a value from the list or typing a value contained in the list would navigate the user to the next state, which is to specify a size for the pizza. But we are not at that point yet.

Assist Users with Prompts

Using Apache FreeMarker expressions in Oracle Digital Assistant, you can display text messages conditionally. So for the next user experience adjustment, after the first failed user input attempt, you are going to tell the user that the provided pizza type is not valid and that only a pizza from the menu list can be chosen.

  1. Edit the text property in line 39 and change it from
    text: “What pizza do you like?”
    
    to (all in a single line)
    text: "<#if system.invalidUserInput == 'true'>Sorry, \"${system.message
    .messagePayload.text}\" is not a valid pizza type. Please choose a value from 
    the menu. What pizza do you like?"
    
    Note: The value string above is provided in the starter folder of the download resources for this article. You can find it in a text file named step-44_textProperty.txt.
  2. Run the embedded conversation tester by clicking the Skill Tester icon ().
  3. Type I like to order pizza into the Message field and press the Enter key.
  4. When the list of values appears, type salami into the Message field and press the Enter key. Notice the prompt displayed with the pizza type list, which now repeats your text input, mentioning that the input is not valid and asking you to choose a value from the menu.
  5. Click Reset and close the tester.

What you just did: Apache FreeMarker is an open source templating engine and expression language that is used in the Oracle Digital Assistant dialog flow. The internal invalidUserInput system variable is set to true after the first failed attempt of a user to provide a valid data input. The Apache FreeMarker <#if>-directive is then used to repeat the provided user message along with a text message explaining what the user should do next.

Allow User to Actively Cancel or Request Help

So far, so good; but as long as there is better, just good is not enough. With your improvements, the pizza skill nicely guides users on what to do, and it still cancels the pizza order when the value in the maxPrompts property, which defines the maximum number of failed user input attempts, is exceeded. Instead of the chatbot automatically exiting the validation loop, let’s make the user do so intentionally.

  1. Go to line 35 and remove the value set for the maxPrompts property. This change configures the askPizzaType state to go into an infinite validation loop when the user does not provide a valid value for the pizza type.
  2. Go to line 46 and edit the askPizzaType state with the content highlighted in Figure 3. Make sure the indenting looks exactly as in the figure. The newly added globalActions element aligns with the responseItems element in line 37.

    chatbots figure 3 Adding conditionally displayed buttons for canceling and getting help

    Figure 3: Adding conditionally displayed buttons for canceling and getting help

  3. Go to line 63, which defines the cancel action, and create a new help action in the row below.
  4. Set the value of the help action to "gettingHelp", as shown in Figure 3.
  5. Run the embedded conversation tester by clicking the Skill Tester icon ().
  6. Type I like to order pizza into the Message field and press the Enter key.
  7. Then, type salami into the Message field and press the Enter key.
  8. Notice two buttons displayed at the end of the pizza type list: Help and Cancel.
  9. Click the Cancel button to see the cancel message, as before.
  10. Again, type I like to order pizza into the Message field and press the Enter key.
  11. Type salami into the Message field and press the Enter key.
  12. Click the Help button and notice the help that is provided by the bot.

What you just did: In this part of the hands-on exercise, you created two global buttons that are displayed after the first time a user fails to provide a valid data input. Instead of using Apache FreeMarker expressions to display the buttons, you used the onInvalidUserInput property (line 57 of Figure 3) of the System.CommonResponse component. Each button triggers an action that is mapped to an action transition: cancel (line 63) and help (line 64). Now the skill behavior is that the user remains in the validation loop until one of the two buttons is clicked.

Implement Help Using Oracle Instant Apps

Often users don’t need help but just a better interface. This is especially true when users get stuck in a longer conversation flow. They don’t appreciate provided help that interrupts the conversation for them and makes them start over.

Oracle Instant Apps are reusable microscoped web applications you build declaratively for use in the context of a skill bot conversation. At runtime, instant apps are executed in the mobile device’s web view or a browser window outside of the conversational channel.

Oracle Instant Apps lets bot designers create instant apps to provide users with an easy way for entering structured form data into a bot conversation. When stuck in a bot conversation, users tend to be frustrated with the conversational medium. This is where Oracle Instant Apps can improve the user mood and user experience.

  1. Go to line 105 and remove the complete gettingHelp state. Figure 4 shows the content you should delete.

    chatbots figure 4 Content to delete from the dialog flow

    Figure 4: Content to delete from the dialog flow

  2. Go to the top of the dialog flow builder and click the green + Components button.
  3. In the opened dialog box, click the User Interface category.
  4. In the menu to the left, select the Interactive entry.
  5. Set the Insert After item to askPizzaSize.
  6. Enable the Remove Comments toggle.
  7. Click the Apply button.
  8. Back in the dialog flow, change the interactive state name to gettingHelp.
  9. Edit the properties shown in the following table and apply the values shown in the table (including the quotation marks):
    Property Value
    sourceVariableList "pizzaType,pizzaSize"
    variable "instantAppReturn"
    id "oraclepizzahelp "
    title "Oracle Pizza Help"
    description "Use web form to complete your order"
    linkLabel "Click to complete order"
    cancelLabel "Cancel order"
    prompt "Complete your order in a web form"
    cancel "cancelPizzaOrder"
    textReceived "cancelPizzaOrder"
    Your gettingHelp state should now look like it does in Figure 5.

    chatbots figure 5 GettingHelp configuration to launch Oracle Instant Apps

    Figure 5: GettingHelp configuration to launch Oracle Instant Apps

  10. Navigate to the transitions: element in the gettingHelp state and place the cursor at its end.
  11. Create a new line.
  12. Add next: "setPizzaType" and make sure the next: label vertically aligns with the actions: label below it.
  13. Go to the top of the dialog flow builder and click the green + Components button.
  14. In the opened dialog box, select the Variables category.
  15. In the menu to the left, select the Set variable entry.
  16. Set the Insert After item to gettingHelp.
  17. Enable the Remove Comments toggle.
  18. Click the Apply button.
  19. Back in the dialog flow, change the setVariable state name to setPizzaType.
  20. Configure the setPizzaType state as shown in Figure 6.

    chatbots figure 6 setPizzaType configuration

    Figure 6: setPizzaType configuration

  21. Repeat steps 73–80, using the settings in the following table:
    Property Value
    state name setPizzaSize
    variable "pizzaSize"
    value "${instantAppReturn.value.pizzaSize} "
    next "askPizzaType"
    The state should look like it does in Figure 7.

    chatbots figure 7 setPizzaSize state

    Figure 7: setPizzaSize state

  22. You are ready to test the new help. Open the embedded conversation tester.
  23. Type I like to order pizza into the Message field and press the Enter key.
  24. Then, type salami into the Message field and press the Enter key.
  25. Click the Help button. This displays the bot response shown in Figure 8, so you can launch the Oracle Instant Apps web form.

    chatbots figure 8 setPizzaSize state

    Figure 8: Oracle Instant Apps launch UI

  26. In the Oracle Pizza Help bot response, click the Click to complete order link to launch the Oracle Instant Apps form in a separate tab.
  27. In the opened form, select a pizza type and a pizza size.
  28. Click the Order button.
  29. Close the current (Oracle Instant Apps) browser tab.
  30. Back in the tester, you should see the order completed and confirmed with the selected form values.
  31. Click the Reset button.
  32. Type I like to order pizza into the Message field and press the Enter key.
  33. When the pizza type list of values is displayed, select a pizza type from the list.
  34. When prompted for the pizza size, type extra and press the Enter key.
  35. As it did for of the pizza type list, a Help button is displayed. Click the Help button.
  36. The Oracle Instant Apps form is displayed with the selected pizza type set, but with no size selected. Select a pizza size.
  37. Click the Order button.
  38. Close the current (Oracle Instant Apps) browser tab.
  39. Again, the tester window should show the selected pizza type and size.
  40. Click the Reset button.
  41. Close the embedded tester window.

What you just did: In this part of the hands-on exercise, you implemented user help in the form of an instant app. Now, when a user fails to provide a valid data input when prompted for the pizza type or pizza size, the displayed Help button launches an instant app, which allows the user to use a web-based input form to complete the order. Any value that the user provides within the bot conversation is already set in the form. Using a web form for providing help unlocks users by providing them an environment they are familiar with. When the user closes the instant app by clicking the Order button, control is passed back to the bot along with the user-selected values. The setPizzaType and setPizzaSize states copy the values returned from the Oracle Instant Apps form to the dialog flow variables used within the chatbot conversation.

Human Agent Integration

Another option to assist users in escaping the validation loop and to successfully complete a task (such as pizza ordering in this hands-on exercise) is to pass the conversation to a human agent. Oracle Digital Assistant integrates with human agent support such that the same conversation and channel can be used for a human to interact with the user. After the human agent helps the user, control is then passed back to the bot.

With human agent integration, you now know about three levels of escalation for unlocking users in a bot conversation: written help, Oracle Instant Apps, and human agent integration.

Intelligent Routing in Oracle Digital Assistant

Imagine that, when asked to select a pizza type, a user types Ask Trust Bank, what is my balance, just to check if he can afford a big pizza with everything on it. In this case, the user is not locked because he understands the order process for a pizza. It’s just that the user has a question he needs to get resolved first. Here, the expected bot behavior is that, temporarily, the user is allowed to exit the existing conversation.

Subflows, which in Oracle Digital Assistant are referred to as nonsequitur navigation, are automatically handled by Oracle Digital Assistant smart request routing. If Oracle Digital Assistant has a “Trust Bank” skill defined, the user is able to exit and return to the pizza ordering conversation. So there is nothing more that bot designers need to code for.

Conclusion

In this article, you improved the user experience of a skill in Oracle Digital Assistant by providing options for users to continue the bot conversation when they don’t know how to provide correct input for a bot response. Conversational design is an important skill to learn for any bot developer because it helps keep users on a happy path when they are working with a bot. Understanding how to allow users to escape the validation loop and to get help is just one important design discipline.

Next Steps

TRY Oracle Digital Assistant.

DOWNLOAD the bot for this article.

LEARN more about Oracle Digital Assistant.

READ an Oracle TechExchange article about escaping the validation loop.

Illustration by Wes Rowell