article by Frank Nimphius, May 2020
Displaying a tip of the day was a very popular feature in client-server applications and on the web. The goal of such tips was to provide easily digestible information that could be fun or help you better understand a program or technology. For some time now I am observing that chatbot developers implement web application functions such as font formatting, dropdown menus, etc. in their web messenger (Oracle Web SDK). So I thought that a tip-of-the-day feature would be cool and engaging for bot users.
Requirements
Unlike other skills, a tip-of-the-day skill should not be invoked from a user message. In other words, you don't want users to type "show me another tip of the day" into the message window just to read more tips. In addition, you want the messenger (Oracle Web SDK) to call the tip of the day silently. Ideally, the tip of the day could be implemented so it can be launched at any time by the web messenger.
The Solution
Oracle Digital Assistant knows of two invocation types for skills: implicit and explicit. Implicit invocation is where a pizza skills responds to "I like to order a small veggie pizza". Explicit invocation is what we all know from Alexa (though the call it a wake up keyword). In Oracle Digital Assistant, each skill has an invocation name. If you mention the invocation name in a user message, then the routing will go to that skill no matter what.
The tip of the day skill
The tip of the day skill is simple to build. It uses resource bundles for the tips. One reason for using resource bundles is that it is easier for maintaining strings. Another reason is that it would be easy to make the tip-of-the-day feature available for other languages as English.
The dialog flow of the tip-of-the day skill uses a System.SetVariable property to write two messages into an array. The reason for using an array is that it allows to use the System.CommonResponse component to print the messages into a single bubble. Because the skill is supposed to be used on the web, the string contains markup to format the header string. The second value line in the System.SetValue component's value property reads a random string from the resource bundle.
At runtime, invoking the skill from the web messenger would display a message as shown below.
So far so good. One trick though is missing, which is to hide the tip-of-the day feature from implicit invocation. This is done by the tip-of-the-day skill not having a single intent defined:
So when the tip-of-the-day skill gets published and then added to the digital assistant, it does not contribute any utterance to the digital assistant classifier. The image below shows 3 skills being added to digital assistant. Notice the TIP_OF_DAY invocation name. If you wanted to obfuscate this event more, for example to ensure nobody could guess the invocation name, you could change the invocation name to a random string like "T3JhY2xlIERpZ2l0YWwgQXNzaXN0YW50IHJvY2tzIQ==". For this sample, TIP_OF_DAY as a name is good.
The JavaScript side of things
So far so good. Once you exposed the digital assistant on the Oracle Web channel configuration, you can access it from the Oracle web SDK (web messenger added to your website or web application). To invoke the tip of the day, you need to send a hidden message, for which you have two options
- Add a property initUserHiddenMessage to the web widget configuration setting.
The "show" in the "TIP_OF_DAY, show" string is of no meaning. It is only needed to send a message to the skill so that it doesn't display a help card.
- The second option is what you can use at runtime, which is a function exposed on the Oracle Web SDK: Bots.sendMessage('TIP_OF_DAY, show', { hidden: true }); . This function can be called at any time within a bot conversation right after the web messenger connected to the bot. The following code snippet show a button that, when clicked, will send a message to the bot to send another tip of the day:
Instead of a button, you could use a time function to send the message, or use a delegate in Oracle Web SDK to listen for the end of a conversation. An end of a conversation can be indicated through a custom channel property on a System.CommonResponse component that sends a secret property. If this property is detected in a delegate object, the delegate could call the sendMessage function to display a tip-of-the-day message. Truly, xour imagination is the only limit.
What else
Displaying a tip of the day and then doing nothing may leave users stunned of what to do next. So in the sample I built, I send a request for a welcome message 3 seconds after the user opened the web messenger widget to read the tp of the day. So the initSDK function of the Oracle Web SDK call sets the following listener after the messenger connected to the bot
The digital assistant is setup so that a message "hi" or "hello" is implicitly routed to the pizza welcome skill. The welcome skill then prints a message as shown below 3 seconds after the user launched the messenger popup window.
After this, conversation continues as expected.
And if a user can't get enough of the tip of the day feature, he or she may try to get more by requesting for it as show below:
Because the tip-of-the-day skill only supports explicit navigation, no user message will be able to launch another tip. The tip-of-the-day is in the control of the messenger client only.
What You Should Know
The tip-of-the-day skill cannot be completely hidden from users. If the digital assistant displays its generated help cards then the tip-of-the-day skill will be listed. The solution to this is to build and configure your own help skill that then doesn't contain information about the tip-of-the-day skill.
Downloads
I am sharing the tip-of-the-day skill with you. The digital assistant I used to demonstrate the feature was quickly built and would not hold as a good programming example. Anyway, you can use the skill as follows
- publish. the skill
- add the skill to a digital assistant
- run the digital assistant from the Oracle Web messenger (Oracle Web SDK)
- Use code like Bots.sendMessage('TIP_OF_DAY, show', { hidden: true }); to show a tip
Related Content
Oracle product documentation about Oracle Web SDK and the web channel
Oracle Web SDK and Web SDK Sample download (see Oracle Web SDK in (for OCI Native environments))
TechExchange: How To Create A Custom Drop-Down Menu In The Oracle Web SDK
TechExchange: How to Optimize The Display of Long Texts in Oracle Digital Assistant Web Messenger
TechExchange: All 2-Minutes Oracle Digital Assistant Tech Tip Videos on YouTube