Virtual Assistants Overview
Natural Language Processing (NLP)
Concepts and Terminology
Help & Learning Resources
Quick Start Guide
Accessing the Platform
Navigating the XO Platform
Building a Virtual Assistant
Using Workspaces
Release Notes
Current Version
Previous Versions
Request a Feature
Conversation Designer
Dialog Tasks
Mock Scenes
Dialog Tasks
Navigate Dialog Tasks
Build Dialog Tasks
Nodes & Connections
Node Types
Intent Node
Dialog Node
Entity Node
Entity Rules
Form Node
Confirmation Node
Message Nodes
Logic Node
Bot Action Node
Service Node
Webhook Node
Script Node
Process Node
Agent Transfer
Node Connections Setup
Context Object
Sub-Intent Scoping
User Prompts
Voice Call Properties
Dialog Task Management
Event Handlers
Supported Entity Types
Supported Company Names
Supported Colors
Knowledge Graph
Knowledge Extraction
Build Knowledge Graph
Create Node Structure
Build the Graph
Add FAQs
Add FAQs from an Existing Source
Run a Task
Traits, Synonyms, and Stop Words
Manage Variable Namespaces
Update Knowledge Graph
Move Question and Answers Between Nodes
Edit and Delete Terms
Edit Questions and Responses
Knowledge Graph Analysis
Knowledge Graph Import and Export
Prepare Data for Import
From a CSV File
From a JSON File
Importing Knowledge Graph
Exporting Knowledge Graph
Auto-Generate Knowledge Graph
Alert Tasks
Small Talk
Digital Skills
Digital Forms
Digital Views
NLP Optimization
ML Engine
Model Validation
FM Engine
KG Engine
Traits Engine
Ranking and Resolver
Training Validations
NLP Configurations
NLP Guidelines
Default Standard Responses
Contextual Memory
Contextual Intents
Interruption Management
Multi-intent Detection
Amending Entities
Default Conversations
Conversation Driven Dialog Builder
Sentinment Management
Tone Analysis
Test & Debug
Talk to Bot
Utterance Testing
Batch Testing
Conversation Testing
Health and Monitoring
Overview Dashboard
Conversations Dashboard
Users Dashboard
Performance Dashboard
Custom Dashboards
Custom Meta Tags
Create Custom Dashboard
NLP Insights
Conversations History
Conversation Flows
Analytics Dashboard Filters
Usage Metrics
Containment Metrics
Smart Bots
Universal Bots
Universal Bot Definition
Universal Bot Creation
Training a Universal Bot
Universal Bot Customizations
Enabling Languages
Manage Assistant
Plan & Usage
Usage Plans
Support Plans
Multilingual Virtual Assistants
Get Started
Supported Components & Features
Manage Languages
Manage Translation Services
Multiingual Virtual Assistant Behavior
Masking PII Details
IVR Settings
General Settings
Assistant Management
Manage Namespace
Data as Service
Data Table
Table Views
App Definitions
Sharing Data Tables or Views
Build a Travel Planning Assistant
Travel Assistant Overview
Create a Travel Virtual Assistant
Design Conversation Skills
Create an ‘Update Booking’ Task
Create a Change Flight Task
Build a Knowledge Graph
Schedule a Smart Alert
Design Digital Skills
Configure Digital Forms
Configure Digital Views
Train the Assistant
Use Traits
Use Patterns
Manage Context Switching
Deploy the Assistant
Configure Agent Transfer
Use Bot Functions
Use Content Variables
Use Global Variables
Use Web SDK
Build a Banking Assistant
Design Conversation Skills
Create a Sample Banking Assistant
Create a Transfer Funds Task
Create a Update Balance Task
Create a Knowledge Graph
Set Up a Smart Alert
Design Digital Skills
Configure Digital Forms
Configure Digital Views
Add Data to Data Tables
Update Data in Data Tables
Add Data from Digital Forms
Train the Assistant
Composite Entities
Use Traits
Use Patterns for Intents & Entities
Manage Context Switching
Deploy the Assistant
Configure an Agent Transfer
Use Assistant Functions
Use Content Variables
Use Global Variables
Intent Scoping using Group Node
Analyze the Assistant
Create a Custom Dashboard
Use Custom Meta Tags in Filters
API Reference
API Introduction
API List
API Collection
koreUtil Libraries
SDK Reference
SDK Introduction
SDK Security
SDK Registration
Web Socket Connect and RTM
Using the BotKit SDK
BotKit SDK Tutorial - Blue Prism
Widget SDK Tutorial
Web SDK Tutorial
Introduction to Admin Console
Administration Dashboard
User Management
Add Users
Manage Groups
Manage Roles
Assistant Management
Invite Users
Send Bulk Invites
Import User Data
Synchronize Users from AD
Security & Control
Using Single-Sign On
Security Settings
Cloud Connector
  1. Home
  2. Docs
  3. Virtual Assistants
  4. Advanced Topics
  5. koreUtil Libraries

koreUtil Libraries

koreUtil libraries provide pre-written JavaScript functions which makes common or complex tasks easy to implement. These libraries often target specific tasks such as setting up recurring rules for calendar, parsing and manipulation of dates, conversion of dates between timezone, tools to simplify programming with strings, numbers, arrays, functions and objects etc.

How to Use

koreUtil libraries can be used anywhere in the assistant where there is a flexibility to write JavaScript code such as script node, message node, confirmation node, entity node, standard responses, answers to FAQs, small talk, event handlers etc.


koreUtil.rrule is a Platform offered JS library for creating new recurrence rules, interpreting and reading them in human readable format. This library is backed by rrule npm module version 2.2.0 installed on the server. For more details on using rrule refer here.

Usage Example:
context.rule = new koreUtil.rrule({
freq: koreUtil.rrule.WEEKLY,
interval: 5,
byweekday: [koreUtil.rrule.MO, koreUtil.rrule.FR],
dtstart: new Date(2012, 1, 1, 10, 30),
until: new Date(2012, 12, 31)

context.between=context.rule.between(new Date(2012, 7, 1), new Date(2012, 8, 1));


  • For context.between
  • For context.readableFormat
    every 5 weeks on Monday, Friday until January 31, 2013


koreUtil.moment is a Platform offered JS library for validating, manipulating, and formatting dates. This library is backed by the moment npm module version 2.19.2 installed on server. For more details on using moment refer here.

Usage Example:

For context.german:
Montag, 18. November 2019 01:43


koreUtil.intl is a Platform offered JS library for language specific string comparison, number formatting, and date and time formatting. This library is backed by intl npm module version 1.2.5 installed on server. For more details on using intl refer here.

Usage Example:
context.formattedNumberUK = koreUtil.intl.NumberFormat('en-GB').format(123456.789);
var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));


  • For context.formattedNumberUK:
  • For context.USdate


koreUtil.momenttz is a Platform offered JS library for formatting of dates in any timezone and convert dates between timezones. This library is backed by moment-timezone npm module version 0.4.1 installed on server is 0.4.1. For more details on using momenttz refer here.

Usage Example:
var jun = koreUtil.moment("2014-06-01T12:00:00Z");
context.newyork= koreUtil.momenttz(jun,'America/New_York').format('ha z'); = koreUtil.moment().tz('Asia/Tokyo').format('ha z'); = koreUtil.moment().tz('Australia/Sydney').format('ha z');


  • For context.newyork:
    5am PDT
  • For
    7pm JST
  • For
    9pm AEDT


koreUtil.xml2js is a Platform offered JS library for parsing xml to json and vice versa. This library is backed by xml2js npm version 0.4.19 installed on server. More details on using xml2js refer here.

Usage Example:
var obj = {name: "John", Surname: "Doe", age: 23};
var builder = new koreUtil.xml2js.Builder();
context.xml = builder.buildObject(obj);


  • For context.xml:
    John Doe 23


koreUtil.hash is a Platform offered JS library that supports SHA on JavaScript. The library is backed by sha.js npm module version 2.4.9 installed on server. For more details refer here.

Usage Example:
context.hashString= koreUtil.hash('sha256').update('42').digest('hex');


  • For context.hashString:


koreUtil._ is a Platform offered JS library which provides utility functions for common programming tasks. This library is backed by lodash.js npm module version 3.10.1 installed on server. For more details refer here.

Usage Example:
context.chunkArray = koreUtil._.chunk(['a', 'b', 'c', 'd'], 2);
var users = [
{ 'user': 'barney', 'age': 36, 'active': true },
{ 'user': 'fred', 'age': 40, 'active': false }
context.filterActive =koreUtil._.pluck(koreUtil._.filter(users, { 'age': 36, 'active': true }), 'user');


  • For context.chunkArray:
  • For context.filterActive:


koreUtil.getCurrentOptions is a Platform offered JS library which provides utility functions to get the current template for language selection standard response options. This can be used to customize the standard response.
Post the release of v8.1, this function has been enhanced to return the authorization URL used in the standard response when end-user authorization is requested.

Following is the return format for each of the situations:

  • For the language selection standard response:
    {"list_of_languages": [
       {"title": "English","value": "English"},
       {"title": "Deutsche","value": "Deutsche"},
       {"title": "Español","value": "Español"}
  • For the language ambiguity standard response:
    {"current_language": "Español",
          "list_of_new_languages": [
             {"title": "English","value": "English"},
             {"title": "Deutsche","value": "Deutsche"},
             {"title": "Español","value": "Español"}
  • For the language switch standard response:
    {"new_language": "Español","current_language": "English"}
  • For User authorization request standard response:
        "authorizationURL": "https:///r/xxxxxxxxxxxxx"

Following are the usage examples of how the above utility can be used to render the message in a button template, you can use any template as per your requirements.  See here for more on message templates.

Usage Example 1: To get the standard response for “Ask if the user would like to select any of the languages

var info = koreUtil.getCurrentOptions();
var message = {
  "type": "template",
  "payload": {
    "template_type": "button",
    "text": "please select your laguage",
    "subText": "Button Template Description",
    "buttons": []
for (i = 0; i < info.list_of_languages.length; i++) {
  var button = {
    "type": "postback",
    "title": info.list_of_languages[i].title,
    "payload": info.list_of_languages[i].value


Usage Example 2: To get the standard response for “Ask if the user would like to switch to any of the new languages detected during a conversation

var info = koreUtil.getCurrentOptions();
var message = {
    "type": "template",
    "payload": {
        "template_type": "button",
        "text": "language ambiguity response for the current language" + info.current_language,
        "subText": "Button Template Description",
        "buttons": []
for (i = 0; i < info.list_of_new_languages.length; i++) {
    var button = {
        "type": "postback",
        "title": info.list_of_new_languages[i].title,
        "payload": info.list_of_new_languages[i].value


Usage Example 3: To get the standard response for “Ask if the user would like to switch to any of the new languages detected during a conversation

var info = koreUtil.getCurrentOptions();
var message = {
    "type": "template",
    "payload": {
        "template_type": "button",
        "text": "would you like to switch to new language detected: current language " + info.current_language + "new language : " + info.new_language,
        "subText": "Button Template Description",
        "buttons": []
var options = ["yes", "no"]
for (i = 0; i < options.length; i++) {
    var button = {
        "type": "postback",
        "title": options[i],
        "payload": options[i]

Usage Example 4: To get the standard response for “User needs to authorize or re-authorize

var info = koreUtil.getCurrentOptions();

var message = {
    type: 'template',
    payload: {
        template_type: 'button',
        text: 'Please authorize before we continue...',
        buttons: [
                type: 'url',
                title: 'Click here to authorize',
                url: info.authorizationURL



The koreUtil.getAmbiguousIntents util function is used to obtain the ambiguous intents list when the Ambiguity Intents Identified event gets triggered. Along with the list of ambiguous intents, the retrieved context object contains additional details such as ambiguity reasons – ‘multiple definite intents’, ‘multiple intents with similar scores’, etc., and the engine name that detects the intent (ML, FM, or KG), the score given by the respective engines, and so on. The Ranking and Resolver score is displayed wherever available.

Usage Example
You can use the koreUtil.getAmbiguousIntents() function in the entity prompt or any other node to obtain the list of ambiguous intents.

Sample Response

"intents": [
"intent": "Transfer Money",
"name": "Transfer Money",
"intentType": "dialog",
"mlScore": 100,
"rrScore": 7980,
"identifyingEngines": {
"ml": true
"intent": "Pay Bills",
"name": "Pay Bills",
"intentType": "dialog",
"rrScore": 0,
"identifyingEngines": {
"traits": true
"intent": "Status of Funds Transfer",
"name": "Status of Funds Transfer",
"intentType": "dialog",
"fmScore": 5330,
"rrScore": 5330,
"identifyingEngines": {
"fm": true
"PrimaryQuestion": "How to Send Money",
"MatchedQuestion": "How to Send Money",
"intentType": "FAQ",
"faqScore": 100,
"rrScore": 7960,
"faqDemystification": {
"path": [
"Money Transfer"
"identifyingEngines": {
"faq": true
"cause": "multipleChoices",
"userInput": "How do I make a payment or transfer"

In this response, we obtain the details of multiple ambiguous intents from different engines.

The type of intent is captured in the intentTypeobject. For example, Status of Funds Transfer is a Dialog-type intent, and How to Send Money is a FAQ-type intent. The identifying engine for that respective intent and the confidence scores assigned by the engines for the intents are captured. For example, for the intent Transfer Money, the mlScoreis 100. The rrScoreis the Ranking and Resolver score for the winning intent. The object faqDemystificationprovides the bot path for the FAQ. The user input and the cause for the ambiguous intents are also captured.


koreUtil.getSessionId is a Platform offered JS library for obtaining the current conversation session Id.

Usage Example:
var sessionId = koreUtil.getSessionId();


  • For sessionId:


koreUtil.closeConversationSession is a Platform function for force closing any active conversation. This function can be invoked from any component that supports JavaScript. When you invoke this function, the Platform will discard any ongoing task and the active conversation session  will be closed. The Platform also presents the session timeout message on the supported channels.

Usage Example:



No response is returned and session ends.

Note: The koreUtil.closeConversationSession is supported in the Platform v8.1 and above versions.


koreUtil.autotranslate is a Platform function that lets you automatically translate the virtual assistant response from a language in which the assistant is configured to the language in which the user is interacting or a language of your choice. This function uses a translation engine to translate the bot responses into user input language. For more information on how to configure a translation engine, refer here.

Please refer below for the translation behavior:

Response Types Components Translation Behavior
Plain Text Responses Refers to plain text responses defined anywhere in the virtual assistant. For example, prompts, responses etc.,

Default: Auto-translated

You can choose to translate only a specific part of the response by using the koreUtil.autoTranslate function only for that part.

Advanced / JavaScript based Responses Refers to responses defined using JavaScript. For example, prompts, responses etc.,

Default: No auto-translation

You can use the AutoTranslation function inside the JavaScript to define the parts of the responses that need translation.

Auto-formatted Responses Refers to the responses that are auto-formatted by the Platform as per the channel specifications. For example, confirmations, list of values, ambiguities etc. Default: Auto-translated

Usage Example:


Here are a few use case examples for your reference:

Use Case-1:To translate part of a sentence in the user’s language:


{{koreUtil.autoTranslate('Welcome! I am a virtual assistant powered by ')}} General Insurance

Output in Serbian

Добредојдовте! Јас сум виртуелен асистент напојуван од General Insurance

Use Case-2:To translate the content of a customized JavaScript template, then use koreUtil.autoTranslate as follows:


var accountBalance = getbalance(); var message = koreUtil.autoTranslate("Your account balance is "); var message = message.concat(env.currency, ‘ ’, accountBalance); print(message);

Output in Serbian

Баланс вашего счета USD 5,278.00

Use Case-3: To translate the bot responses in a particular language by passing the language code. An example where the assistant will respond only in German even though the user is interacting in any language:


var message = koreUtil.autoTranslate("This is a sample message", "de");print(message);

Output in German

Dies ist eine Beispielnachricht