When writing bot response messages and prompts, we recommend using resource bundles – always. The arguments in favor of using respurce bundles are
- Preparing bots for multilingual
- Reuse of message strings
- Ease of string administration and management
- Separating the jobs of skill development and implementing the bot's tone and voice
- Optimizing messages for a specific messenger channel
This article is about the latter argument to prepare digital assistants for use with different messengers, with the ability to optimize text responses for a specific messenger. Even if you do not want your digital assistant to support messengers other than Oracle Web Messenger, you should implement the practice outlined in this article because you do not know how the requirements will change in the future. At the very least, you should consider voice as a possible next channel.
Recommended Practice for Resource Bundles
You can implement the suggestion in this article anywhere you can use resource bundles in Oracle Digital Assistant: skills, custom components, entities, settings.
The example in this article shows the technique for use in BotML. The use in entities and settings however ie very similar.
To refer to a resource bundle key from BotML (YAML), entities, or settings, use an expression like this: $ {rb ('resource_bundle_key')}.
Resource bundle strings that require parameters to be passed can use positional parameters or named parameters. Positional parameters use placeholders such as {0}, {1}, etc. for values that are dynamically passed to the resource bundle at runtime.
For the solution in this article to work, you need to use named parameters.
For example, to pass the named parameters "arg1", "arg2" with the values "valueArg1", "valueArg2", use the following expression: $ {rb ('resource_bundle_key', 'arg1, arg2', 'valueArg1', valueArg2 ).
The values can be provided statically (as shown in the example) or at runtime e.g. from dialog flow variables: $ {rb ('resource_bundle_key', 'arg1, arg2', valueArg1Var.value, valueArg2Var.value).
The figure below shows a dialog flow state that refers to the resource bundle key "sampleMessage.message". The named parameter is "channelType", the value of it is read from a system variable "system.channelType".
Depending on the messenger with which the Oracle Digital Assistant is used, the value transferred as channelType is "websdk", "slack", "msteams", "facebook", "webhook" etc.
The resource string definition for the sampleMessage.message key uses the ICU message format.
One of the operators supported by this format is the "select" operator. With the operator "select" you can write messages that are displayed specifically for a messenger. The reference "other" shown in the picture refers to the message to be printed if the messenger used does not have a specific configuration.
So, in the image below the message is written for all messengers because there is no configuration section to handle messenger specific messages.
At runtime, using the Oracle Digital Assistant skill tester, the message prints as shown in the image above. Notice that the skill tester has its "Channel" set to "Oracle Web" to simulate the use of the Oracle Web messenger.
In the screenshot below, an Oracle Web Messenger specific message is added to the resource bundle string.
A new line web sdk {…} has been added for this purpose. As you can see, the web-specific message uses HTML markup tags to format strings.
If you run the example in the conversational tester, the HTML markup tags will be printed with the message.
In the real world use, at runtime, the formatting tags would be interpreted using the Oracle Web SDK. The conversation tester in Oracle Digital Assistant simulates a web messenger but does not emulate it. Because of this, the HTML tags are displayed as added to the message.
As mentioned, this is during development and testing with the conversation tester only.
Nevertheless, you can see how the web messenger now receives its own optimized message, while other messengers would use the message defined for "others".
What I recommend to you
I recommend to always define resource bundle strings with a "channelType" named parameter as shown in the images.
I also recommend implementing the select operator with the other message definition, as shown in the image for the first example of using resource bundle messages.
During development, using the select operator with the "other" definition is a bit of an overhead that will NOT slow you down.
Following my recommendation will give you the option that every message printed from a resource bundle can be optimized for a specific (or several specific) messenger channels with no need to change anything in the skill code.
Best is you start all resource bundle strings with this template
{channelType, select,
other { default text goes here }
}
Additional Resources
The practice of optimizing digital assistants for different messengers is referred to as "Adaptive Bot Response Design" in this Oracle Digital Assistant Design Camp video.
Resource bundles and the ICU message format are explained in this Oracle Design Camp video. I recommend you watch it from start to end.
It doesn't cover the solution discussed in this article, but it does explain all of the basics and options available with the ICU message format.
All Oracle Design Camp Videos
More Oracle Digital Assistant Design Camp videos can be found as part of the Oracle Digital Assistant product documentation.