article by Frank Nimphius, March 2021

 

I've always been a proponent of using resource bundles in chatbots instead of putting message and prompt strings directly into the dialog flow code.  The option in Oracle Digital Assistant 20.12 and later to create multilingual bots via the multilingual NLU (watch a video about this) does prove me right.

However, I do recommend that you ALWAYS use resource bundles, even if you don't need a multilingual bot or if you use a translation services.

Oracle Digital Assistant 20.12 introduced not only a multilingual NLU, but also a new extended message format for creating resource bundle strings.

Beside others, the new ICU (International Components for Unicode) message format allows you to print messages and prompts based on a condition like the messenger channel being used and to detect plural vs. singular cases requiring different bot responses. 

In preparation to recording a digital assistant design camp session about using resource bundles and the new ICU message format in Oracle Digital Assistant (watch the video here), I created a sample skill that I am now sharing with you in this article.

Note: I'm sharing this pretty simple but technical demo as a starting point for you when learning about using ICU message formats in Oracle Digital Assistant.

About the ICU Message Format

The ICU (International Components for Unicode) message format isn't new to software development, but it is a new addition to Oracle Digital Assistant 20.12 and later that allows skill and digital assistant designers to store logic for displaying bot responses in the message packet itself.

One example that I already mentioned is the detection of the plural form in a message. As an example, have a look at the two image below where a user requests a meeting room to be booked.

The first request is for a meeting room for a single person. The dialog flow asks for whether the requestor is part of the meeting. As the requestor is not part of the meeting, a room for a single person gets booked.



In the second example of the same demo, the number f participants are defined as 7 and the meeting organizer is part of the meeting. The response therefore says that a room gets booked for the organizer and 6 other people.

The answer that computes the number of attendees for when the organizer attends the meeting is defined in a resource bundle (see image below)

Notice that the resource bundle has an offset set to 1. This indicates to the message bundle that when printing the value for the peopleAttending argument, it needs to subtract 1.

Also you see different answers in the resource bundle that gets displayed when no other people attend the meeting, when one other person attends the meeting and when more that one other person attends the meeting.

The logic of which message to show no longer needs to be in the dialog flow.

One more Example

Ordinals help you with "first", "second", "third" and so on wordings. In the example below, a singe resource bundle string is used to print all the labels of a virtual elevator

The dialog flow state uses the following resource bundle references in the dialog flow

As you can see in the image above, the resource bundle key name is 'showElevatorControlPanel.buttons' and the parameter that gets passed in to it is 'floor'. The value of the floor argument is computed from the index of a value list. The image below shows the resource bundle for you to compare with the labels printed in the "elevator" image. Notice the ICU select type to be selectordinal. The values =0,one,two etc. look into the floor argument to decide when to print the associated message, Notice the use of #st#nd#rd, #th. The # character references the value of the floor parameter. In all ICU message formats, the hash character (#) references the value passed into a select type.

I assume that the samples I showed are difficult to understand if this is the first tie you hear about the ICU message format or resource bundles in general. Therefore, let me remind you of the Oracle Digital Assistant Design Camp recording we have on this topic (watch the video here). The video shows the demo I am sharing with this blog in action and gives you and idea how you work with the demo. 

About the Demo Skill

I am not claiming that the demo skill I am sharing is flawless and of production quality. However, it is a resource that shows you ICU message bundles in action so that you can have a look how different selectors get implemented in digital assistant.

To run the skill, you need to 

  • Import the skill (ZIP) into Oracle Digital Assistant 20.12 or later
  • Open the skill
  • Run the conversation tester and type "show demos"

This then shows the following screen listing the demos

Pressing the Show More button does what is written on the tin and displays more demos

Each sample is a stand-alone sample that demos a specific functionality.

For example, running the Date sample will display the current date in different customizable output formats

To find where in the dialog flow this is implemented so you can look at the code, make sure the output message is selected (indicated by the blue background in the conversation tester). Then you look at the last dialog flow step in the conversation path (you can hover the mouse over the state to better read it)

For the date sample, the dialog flow state is showDate. So, navigate to the dialog flow and use ctrl+f in your browser to search for showDate

From this you learn that the resource bundle string key name is showDate.message and that the current date is passed in millisecond (Apache FreeMarker code) to the dateValue parameter. 

Next, open the resource bundle panel and search for showDate.message to see the ICU format message string

And this is how it works for all demos in the skill. 

Just select the message format type you are interested in, look at the conversation path for the last mentioned dialog flow state and then look the dialog flow state up the the dialog flow. From here you learn about the resource bundle key and the arguments that are getting passed in. 

Another interesting sample to watch is the timer that formats time differences in milliseconds and rounds them up and down to the full second

Who Should Use This Demo

This demo makes sense if you have a good understanding of resource bundles and the ICU message format. Both you can get by watching the Oracle Digital Assistant Design Camp video about resource bundles  (watch the video here). So right after watching the video you should be good to look at the sample code shared in the skill you can download from below.

Important to Note!

Don't get distracted by some of the demos that use male/female as a distinguishing argument for a specific message to print. By using male / female I followed a sample  on the ICU online tester website

Male / female is just a value passed to a message and can be replaced by e.g. the channel type used for a conversation, a product category and so on.

However, gender plays an important role in some languages where messages have different words or endings based on whether a user is male or female. Keep in mind that resource bundles are your ticket to multilingual bots.

Download of Sample Skill

Sample Skill (ICU Demo skill)

Related Documents

ICU message format in the Oracle Digital Assistant product documentation

TechExchange Quick-Tip: Implement Adaptive Bot Design Using Message Bundles In Oracle Digital Assistant

TechExchange: Building A Frequently Asked Question Skill Using A Programming By Convention Approach

TechExchange Quick-Tip: How To Create Randomized Bot Responses Using Resource Bundles in Oracle Digital Assistant

ICU-TC home page

ICU quick guide (the weather example gives you an alternative sample of using a select type)

ICU format online editor

 

Author