article by Frank Nimphius, November 2020

 

Update June 2021: For this to work with ODA 21.06 you need to delete the value added to the "Extract With" field of the car type bag item 

 

Parent-child relationships are a common pattern in software development. The relationship usually describes a one-to-many dependency between two sets of data, one of which (the child) depends on the choice of the other (the parent). For example, a chatbot that handles expenses may prompt a user for providing the type of an expense, which could be accommodation, transportation, parking fees, office supplies and many others. Then, if a user selects transportation as the type of expense, the system may prompts with a dependent list of options, that may include flight, rental car, train, taxi, bus, others  as selectable values.

This article explains how to define parent-child relationships in Oracle Digital Assistant using the System.CommonResponse component and a composite bag entity. It's one more article on the topic of model-driven conversations (see:  TechExchange: Model Driven Conversations in Oracle Digital Assistant – Build Better User Interfaces By Using Entities For Everything )

 

Example

The example you can download for this article is a skill that shows car manufacturers and their dependent car types. As shown in the image below, a use could type a message like "show a list of cars" for the chatbot to display a list of manufacturers.

When the use selects a manufacturer from the list, then the dependent list contains the available car types for this selection.

Note: Both lists display a Show More button that is automatically generated to indicate that there are more values to choose from than the 3 displayed in the list (the number of list items can be configured on the composite bag entity for each bag item)

If a user sends a message that already includes the manufacturer name, then only the list of car types is displayed as shown in the image below

Implementation

As mentioned, the implementation is through the use of a composite bag entity and a system.CommonResponse component (you could use the System.ResoveEntities component too)

Composite Bag Entity

Just in case you don't know. Composite bag entities group custom and built-in entities to real-world objects (domain objects) that are auto-magically resolved in a conversation. The domain entity objects allow you to design Oracle Digital Assistant conversations as model-driven conversations, which not only are more intelligent and robust but also require less code to be written.

The image above shows the entities involved in the sample you can download. Two value-list entities define the car manufacturers and the car types. The name of the car manufacturers are defined as synonyms on the cart type values. For example, a BMW X3 (type) has its synonym set as X3 and BMW. Same for the X5. This means that if a user references "BMW" in a message, the entity, which is configured for a single value selection, triggers a disambiguation list to be displayed. 

The cbe.cars entity is a composite bag entity that contains two bag items: the list.carManufacturers and list.carsByManufacturer entity references. 

The Manufacturers bag item has its Out of Order Extraction option enabled so that if the manufacturer name shows in a message sent to the System.Intent component, the value gets set to bag item (which means that the user is not prompted to select a manufacturer). The second bag item too has its Out of Order Extraction property enabled so the list of car types can be filtered accordingly.

In addition the extract with property of the CarTypes bag item is set to the Manufacturers bag item so that when the user gets prompted for a manufacturer the input will also update the dependent child. And because the manufacturer name is contained as a synonym of the car types, a list of values gets displayed for the user to select a value. Notice that the prompt that is displayed for the child list of values is actually the disambiguation prompts defined on the entity.

System.CommonResponse component

I could have called this article "Establish a No-Code Conversational Parent-Child Relationship Using Value List Entities in Oracle Digital Assistant" because the configuration in the dialog flow is declarative only. What I needed to do was

1. Create a variable cars of type cbe.cars

2. Press the + Components button in the dialog flow and select the User Interface category. Choose the common response – composite bag entry to add it to the dialog flow

3. In the dialog flow state, set the variable property value to cars and the nlpResultVariable to iResult (the nlpresult variable name)

The rest got generated by Oracle Digital Assistant. 

Download

Download the sample skill using the link below. Import it to Oracle Digital Assistant 20.08 or later, train it and then run it using the embedded conversation tester: E.g. "Show cars"

Download Skill

Related Content

TechExchange: How-to Use the System.ResolveEntities Component in Oracle Digital Assistant

TechExchange Quick-Tip: Understanding Oracle Digital Assistant Skill Entity Properties – Or, What Does "Fuzzy Match" Do?

TechExchange: Use Entities To Build Powerful, Robust And Speech-Ready Action Menus

TechExchange: Model Driven Conversations in Oracle Digital Assistant – Build Better User Interfaces By Using Entities For Everything

TechExchange Quick-Tip: How to Intelligently Cancel Composite Bag Entity Driven User Dialog Flows

TechExchange-QuickTip: Creating Multi-Select Lists in Oracle Digital Assistant

TechExchange Quick-Tip: Setting Composite Bag Entity Item Values From A Custom Component

TechExchange: All 2-Minutes Oracle Digital Assistant Tech Tip Videos on YouTube

Author