At times one wants to control the flow of the virtual assistant by taking an alternate path to improve the user’s experience.
Consider the following scenarios:
- The NLP engine might have identified an intent based on the user utterance. But a different task might be more suitable based on additional information gathered from the backend systems or from the webpage where the SDK is hosted or any other external information.
- Consider a flight booking virtual assistant that greets the user with the best ongoing deals as part of the Welcome message. Based on the user selection, the ‘book flight’ task can be programmatically invoked by prepopulating the travel details like source city, destination city, travel, etc. from the deal information presented to the user.
Kore.ai provides a way to pass information to the virtual assistant programmatically using nlMeta data. This can be used in the BotKit SDK, Widget SDK, and web SDK to pass information like intent to be triggered along with the entity values, and other task settings as per your need.
nlMeta
nlMeta is an object which can be used to pass information to the bot. The bot would use this information to execute the intent specified therein before attempting at decoding any other information.
Sample
The following is a sample of how the nlMeta object needs to be populated:
'nlMeta': { 'intent': '<intent_name>', 'childBotName': '<child_bot_name>', 'isRefresh': <true/false>, 'entities': { '<entity1_value>': value1, '<entity2_value>': value2, }, 'interruptionOptions': { 'hr': { 'h': 1; 'r': 1; 'nn': true } } }
Parameters
The following are the parameters that can be used in this object:
Parameters | Description | ||||||
---|---|---|---|---|---|---|---|
nlMeta | An object for natural language information for the bot | ||||||
intent | Intent identified via 3rd party which needs to be triggered by the bot | ||||||
childBotName (in case of Universal Bots) |
Only used in case of a universal bot to identify the child bot intent to trigger. This is also needed when trying to use a widget from the child bot in the universal bot’s panel. | ||||||
entities | Object with entity-value pairs as needed by the intent to be triggered | ||||||
isRefresh |
|
||||||
interruptionOptions | To indicate the interruption behavior, in case any task is in progress when the bot receives this nlMeta information. Values can be:
|
In case, the requested task is not found the bot would respond with a standard response “Dialog task required for conversation not available”.
Usage
As mentioned, nlMeta can be populated and sent to the virtual assistant via BotKit SDK, and web/widget SDK. The following illustrates how it can be accomplished:
- BotKit SDK – as part of metaInfo object:
data.metaInfo = { 'nlMeta': { 'intent': 'Authenticate User', 'isRefresh': true, 'entities': { "Name": "John" }, 'interruptionOptions': 'discardAll' } }
- Web SDK – the nlMeta information can be sent as a parameter using the sendMessage function. You can find this function in the chatWindow.js file. Add a condition when the nlMeta data needs to consumed as follows:
if(_this.text() == “Existing”){ me.sendMessage(_this, attachmentinfo, {'nlMeta': { 'intent': 'Authenticate User'}}); } else{ me.sendMessage(_this, attachmentinfo); }
In the above example, the Authenticate User intent would be triggered if the text field contains the value “Existing”.
- Widget SDK – the nlMeta information can be sent as part of the payload for various templates like button, menu, list, etc., see here for details