article by Frank Nimphius, February 2021
Read-only messages are bot responses that provide a confirmation or an acknowledgement to the user.
The component in Oracle Digital Assistant that 99.5 % of all Oracle Digital Assistant developers use for read-only messages is the System.Output component and there is nothing wrong with it.
However, did you know that the System.CommonResponse component too can be configured to display read-only messages? This article explains this option and outlines use cases and benefits.
Using the System.Output component
The System.Output component is simple and straight forward to use. You find it as a component template in the dialog flow editor. For this you select the + Components button and then the User Interface category.
In the user interface category you then select the Output item to add a dialog flow state configured with the System.Output component to the dialog flow
This then adds the following BotML to the dialog flow (I only added the resource bundle reference for the string to display)
Because I am discouraging anyone from using implicit navigation, I suggest you change the code as shown below
Note: If the message should be printed at the end of a conversation, you would replace the next transition with a return: "done" transition.
Using the System.CommonResponse component
For the System.CommonResponse component, there is no "Output" template but a "Text" template that you can change to render a read-only message. As for the System.Output component, you start with the component template's User Interface category
Select the Common response – text item
The template adds the following content, which initially may look overwhelming.
However, as you will see next, most of the generated code can be removed as shown below:
The code in the image above shows the same output as the System.Output component. Notive that the processUserMessage property is set to false, which actually is the secret sauce that turn the System.CommonResponse component into a read-only component.
Looking at the code in the image above, you may wonder what's the benefit of using the System.CommonResponse component instead of the System.Output. The answer is that there is none if you keep it with this minimal configuration.
To see benefits, you need to look at an extended version shown in the image below
This code actually renders a read-only message that displays a link at its end (and it could even render many links)
So if the skill was a customer service skill that, at the end of a conversation or user request, displays a list of external links, then the System.CommonResponse component is a much better option than adding HTML anchors to the message itself (which then only works on the web SDK).
But there are other options the System.CommonResponse component offers, like the footer and header text properties.
At runtime the message is sent as shown below. As you can see, the header text and footer text could be used to wrap a message in a standard template that (in the case of the footer) engages with the user.
The example shown below shows how to display different messages for different channels. The first text response will be rendered for all messenger channels except Web SDK, whereas the second is displayed when the channel is the Web SDK
You can also use Apache FreeMarker expressions in the expression: property to conditionally show or hide messages.
One more feature of the System.CommonResponse component is to reference an array that allows you to print multi line text. The image below creates an array of messages using the System.SetVariable component. The array however could also come as a response of a custom component call. As you see in the image below, the array variable name is set as the value of the "iteratorVariable" property of the textResponse object. The messages can be printed in their own bubble, or as shown in this example, in a single bubble
And here is the printed message in a single bubble.
Conclusion
Use case matters! Most of the time, using the System.Output component is sufficient for printing a read-only bot response. If the use case demands for a more sophisticated message getting printed then the full powers of the System.CommonResponse component can be used. All you need to do is to set the precessUserMessage property to false and the keepTurn property true. Play with this options and your bot responses will change to better – forever.
So what does not work with System.CommonResponse components set to read-only?
What doesn't work with read-only System.CommonResponse components are postback actions. Postback actions require the component to process the user message, which is what it doesn't do when setting the processUserMessage property to false.
Related Content
TechExchange Quick-Tip: Printing Multi-Line Text Messages from an Output component
TechExchange Quick-Tip: Optimize Bot Responses for a specific Channel in Oracle Digital Assistant