By Frank Nimphius
Oracle Digital Assistant is the next generation of the Oracle chatbot platform. It manages and coordinates multiple smaller-scope skill bots in a composite chatbot solution that helps users complete multitask conversations.
Dialog flows in Oracle Digital Assistant skill bots define the user/bot conversations needed for completing a specific business task. A dialog flow is like a script whose goal is to understand what a chatbot user wants and collect the information needed to perform a particular task. Like human agents in customer service, chatbots can skip portions of a scripted conversation if the information to be collected has previously been provided by the user.
Before Oracle Digital Assistant, chatbots built with the Oracle Cloud platform required a dialog flow state to be defined for each information entity. For example, to create a chatbot for ordering pizza, you needed to create separate dialog flow states to ask for the pizza type, to ask for the pizza size, to ask for the type of crust, and to ask for additional toppings.
With Oracle Digital Assistant, you are no longer required to write all of these separate dialog flow states. Instead, using the new composite bag entity feature, you can group related information into a composite data object. The composite data objects are then automagically resolved at runtime.
This article provides an overview of composite bag entities. Following the hands-on instructions, you will build a composite bag entity for a pizza ordering bot that you then use to reduce the number of dialog flow states in the provided sample bot.
In general, you use entities to extract important information from user messages through natural-language processing (NLP). Entities in Oracle Digital Assistant can be of various types, including value list, entity list, regular expression, entities derived from other entities, and composite bag.
Entities are associated with context variables in the bot dialog flow. If the value of an entity gets extracted from the user message through NLP, then the UI component that references the context variable associated with the entity is not rendered, meaning that users will not be prompted for information they have already provided.
Composite bag entities in Oracle Digital Assistant enable you to define entities and variables of type string, location, and attachment as attributes—bag items—of a single object. When a composite bag entity is resolved at runtime, a prompt gets generated for each entity type attribute that did not get its value from the user message through entity extraction in NLP.
In this article’s pizza ordering bot sample, the composite bag entity describes the pizza the user attempts to order. The pizza composite bag entity object contains attributes referencing the PizzaType, PizzaSize, PizzaCrust, and CheeseType entities. In addition, a pizza object may have a customer name attribute associated with it, so the waiter can identify the customer.
At runtime, composite bag entities are referenced through a context variable that has the custom composite bag entity defined as its type. To resolve a context variable of a composite bag entity type in a dialog flow, you create a dialog flow state that uses the System.ResolveEntities or the System.CommonResponse component for rendering the bot response. Both components are able to render user prompts as input text and lists.
The difference between the two system components, when used with composite bag entities, is that the System.CommonResponse component enables you to customize the rendered bot UI.
Composite bag entities, however, can do more than just group entities and variables into a single object. For each item in a composite bag entity, you can define validation rules, prompts, support for multiple values, fuzzy matching, and other features. For entity references to value list entities, you can specify or inherit a range size value that determines when pagination controls should automatically be displayed.
Both the System.ResolveEntities and the System.CommonResponse components enable you to visit other dialog flow states.
In Oracle Digital Assistant, child bots are referred to as skills, or skill bots. In the hands-on instructions for this article, you are working with a skill bot only. Skill bots in Oracle Digital Assistant can be tested standalone with the embedded tester.
A starter skill bot is provided, so you can focus on building and implementing the composite bag entity, following the instructions in this article.
These 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.
Note: If you don’t see the imported bot because other bots fill your screen, type OracleMagazine into the Filter field above the + New Bot tile.
Note: In Oracle Digital Assistant, the tester opens in full window view. To switch back to the bot, click the Close button.
What you just did: You just explored the functionality of the simple pizza order skill. Note that for this article and its hands-on instructions, the order in which the bot responses are displayed and how they are getting displayed are relatively unimportant. In a real bot implementation, user experience matters and the UI should be more pleasing to the eye. For this article, it is important for you to understand how this little bot conversation is built, which is what you will do next.
All bot conversations are defined as dialog flows in the dialog flow builder. Take a look at some dialog flow content to see how it is used in a bot conversation.
Note: All of these conversation states are required to collect the information necessary for ordering a pizza. The variables that are populated within the states are of an entity type and are defined in lines 9–11.
Line 12 defines the iResult variable, which is of type nlpresult. This variable is used to extract information from the user message.
Composite bag entities help reduce the overall number of dialog flow states needed for a task such as ordering pizza. To prepare to use a composite bag entity in the pizza order skill bot, you first need to clean up the current dialog flow.
Figure 1: OrderPizza action transition value changed to “getOrder”
What you just did: You prepared the dialog flow for adding a composite bag entity variable state. The OrderPizza transition action is followed when the NLP engine understands the user message as a pizza order. The value of this action needed to change, because you removed the getCrust state. You will create the getOrder state later in the hands-on instructions.Composite bag entities are composed of existing entities as well as variables of type string, attachment, and location.
The starter skill bot comes with the following entities defined: CheeseType, PizzaCrust, PizzaSize, and PizzaType. Following the instructions in this section you are going to create a new composite bag entity with the name PizzaOrder.
Note: The only other property of interest for this article is the Prompts property. Here you can define one or more user prompts that get randomly displayed for an entity if the entity is resolved by the System.ResolveEntities or System.CommonResponse component. If an entity is referenced in a composite bag entity, then the defined prompts are used if they are not overridden in the composite bag entity.
Note: The Name field value doesn’t need to be set to the name of the entity it references. You can define any name you like for a bag item. The name of the bag item will be referenced in the dialog flow to read the value saved for an entity.
Note: At this time, a dialog box appears with the following message: “Entity CheeseType has been set to the bag item PizzaType. Do you want to copy over its properties also here? Any edits previously made to this bag item will be lost. Are you sure you want to continue?” Ignore this message, and close the dialog box, by clicking the X icon in the header.
Name | Type | Entity name |
PizzaSize | Entity | PizzaSize |
PizzaCrust | Entity | PizzaCrust |
Figure 2: Intent tester with PizzaOrder entity resolved from the user message
What you just did: In this part of the hands-on instructions, you created a composite bag entity to hold the pizza order information. The order in which entities are added as bag items to a composite bag entity is the default order in which the entities are resolved at runtime. (You can also change the order by changing the configuration.) Finally, you associated the entity with the OrderPizza intent and tested the entity extraction through NLP in the embedded tester.
Next, add the use of the composite bag entity to the dialog flow.
To use the PizzaOrder composite bag entity in the pizza order skill bot, you need to associate it first with a context variable. The variable is then referenced from a dialog flow state with the System.ReferenceEntities component. In the end, when testing the bot, the behavior is the same as in the starter skill bot, although with fewer lines of code to write.
pizzaOrder: "PizzaOrder"
next: "done"
Note: The next element must be indented two spaces, but the transitions element does not.
Property | Value |
Variable | "pizzaOrder" |
nlpResultVariable | "iResult" |
Note: The getOrder state should now look like it does in Figure 3.
Figure 3: getOrder state after the changes
"Your ${size.value} ${type.value} Pizza is on its way."to (in a single line)
"Your ${pizzaOrder.value.PizzaSize}, ${pizzaOrder.value.PizzaCrust} ${pizzaOrder.value.PizzaType} is on its way."
What you just did: In this section, you created a new context variable for the PizzaOrder entity. When testing the bot conversation, you could see that the user is prompted to provide information that was not contained in the initial user message.
Besides reducing the lines of code that need to be written for a user/bot conversation, composite bag entities make it really easy to add or remove information:
"Your ${pizzaOrder.value.PizzaSize}, ${pizzaOrder.value.PizzaCrust} ${pizzaOrder.value.PizzaType} is on its way.”to
"Your ${pizzaOrder.value.PizzaSize}, ${pizzaOrder.value.PizzaCrust} ${pizzaOrder.value.PizzaType} with ${pizzaOrder.value.Cheese} is on its way."
What you just did: With minimal effort, you added information to the PizzaOrder composite bag entity. A change like this requires more work if the order process uses dialog flow states to collect the individual pieces of required information. This certainly is another argument for using composite bag entities.
Note: Before adding any entity as a bag item, you always set the name of the bag item to the name of the entity it references. The bag item name is what is getting referenced when composite bag entity values are being accessed. This is why ${pizzaOrder.value.Cheese} is used in the confirmation message instead of ${pizzaOrder.value.CheeseType}.
Composite bag entities in Oracle Digital Assistant enable you to group related information in a single object, an object that is comparable to a business domain object. Changes applied to composite bag entities have an immediate impact on the bot/user conversation.
In this article and its hands-on instructions, I introduced the concepts and basic use of composite bag entities. Advanced functionality such as value disambiguation, fuzzy matches, validation, error messages, and multiple entity values are also worth mentioning, although they fall outside the focus of this introductory article.
READ “Oracle Digital Assistant Version 18.4.3 Introduces Skill Chatbot Capability.”
DOWNLOAD the bot for this article.
Illustration by Wes Rowell