Chatbot Overview
Conversational Bots
Intents & Entities
Intelligent Bots
Kore.ai's Approach
Kore.ai Conversational Platform
Bot Concepts and Terminology
Natural Language Processing (NLP)
Bot Types
Bot Tasks
Starting with Kore.ai Platform
How to Access Bot Builder
Working with Kore.ai Bot Builder
Building your first Bot
Getting Started with Building Bots
Using the Dialog Builder Tool
Creating a Simple Bot
Release Notes
Latest Updates
Older Releases
Bot Builder
Creating a Bot
Design
Develop
Dialog Task
Working with User Intent Node
Working with the Dialog Node
Working with Entity Node
Supported Entity Types
Working with Composite Entities
Supported Time Zones
Supported Colors
Supported Company Names
Working with Message Nodes
Working with the Confirmation Nodes
Working with Service Node
Implementing Custom Authentication
Enabling 2-way SSL for Service nodes
Working with Script Node
Working with Agent Transfer Node
Working with WebHook Node
Defining Connections & Transitions
Managing Dialogs
Prompt Editor
Action & Information Task
Working with Action Tasks
Working with Information Tasks
Establishing Flows
Alert Tasks
Working with Alert Tasks
Managing Ignore Words and Field Memory
Knowledge Graph
Terminology
Building Knowledge Graph
Generation of Knowledge Graph
Importing and Exporting Knowledge Graph
Knowledge Graph Analysis
Knowledge Extraction
Natural Language
Overview
Machine Learning
ML Model
Fundamental Meaning
Knowledge Graph Training
Traits
Ranking and Resolver
NLP Detection
NLP Settings and Guidelines
Bot Intelligence
Overview
Context Management
Session and Context Variables
Context Object
Dialog Management
Sub-Intents
Amend Entity
Multi-Intent Detection
Sentiment Management
Tone Analysis
Sentiment Management
Default Conversations
Default Standard Responses
Channel Enablement
Test & Debug
Talking to Bot
Utterance Testing
Batch Testing
Recording Conversations
Publishing your Bot
Analyzing your Bot
Overview
Dashboard
Custom Dashboard
Conversation Flows
Bot Metrics
Advanced Topics
Bot Authorization
Language Management
Collaborative Development
IVR Integration
Universal Bots
Defining
Creating
Customizing
Enabling Languages
Smart Bots
Defining
Sample Bots
Github
Asana
Travel Planning
Flight Search
Event Based Bot Actions
Bot Settings
Bot Functions
General Settings
PII Settings
Customizing Error Messages
Bot Management
Using Bot Variables
API Guide
API Overview
API List
API Collection
SDKs
SDK Overview
SDK Security
SDK App Registration
Kore.ai Web SDK Tutorial
Message Formatting and Templates
Mobile SDK Push Notification
Web Socket Connect & RTM
Using the BotKit SDK
Installing the BotKit SDK
BotKit SDK Configuration
Events for the BotKit SDK
Functions for the BotKit SDK
BotKit SDK Tutorial – Agent Transfer
BotKit SDK Tutorial – Flight Search Sample Bot
Using an External NLP Engine
Bot Administration
Bots Admin Console
User Management
Managing Users
Managing Groups
Managing Role
Bots Management
Enrollment
Inviting Users
Sending Bulk Invites to Enroll Users
Importing Users and User Data
Synchronizing Users from Active Directory
Security & Compliance
Overview
Using Single Sign-On
Cloud Connector
Analytics
Billing
How Tos
Context Switching
Using Traits
Live Agent Transfer
Schedule a Smart Alert
Configure Agent Transfer
Custom Dashboard
Patterns for Intents & Entities
Build Knowledge Graph
  1. Home
  2. Docs
  3. Bots
  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 bot 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.

List of koreUtil libraries

Below is the list of koreUtil libraries provided by the platform:

koreUtil.rrule

koreUtil.rrule is 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 Kore.ai 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));
context.readableFormat=context.rule.toText();

Output:

  • For context.between
    [
    "2012-08-27T10:30:00.000Z",
    "2012-08-31T10:30:00.000Z"
    ]
  • For context.readableFormat
    every 5 weeks on Monday, Friday until January 31, 2013

koreUtil.moment

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

Usage Example:
context.german=koreUtil.moment().locale('de').format('LLLL');

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

koreUtil.intl

koreUtil.intl is 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 Kore.ai 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));
context.USdate=koreUtil.intl.DateTimeFormat('en-US').format(date);

Output:

  • For context.formattedNumberUK:
    123,456.789
  • For context.USdate
    12/20/2012

koreUtil.momenttz

koreUtil.momenttz is 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 Kore.ai 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');
context.tokyo = koreUtil.moment().tz('Asia/Tokyo').format('ha z');
context.sydney = koreUtil.moment().tz('Australia/Sydney').format('ha z');

Output:

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

koreUtil.xml2js

koreUtil.xml2js is 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 Kore.ai 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);

Output:

  • For context.xml:
    John Doe 23

koreUtil.hash

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

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

Output:

  • For context.hashString:
    73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049

koreUtil._

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 Kore.ai 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');

Output:

  • For context.chunkArray:
    [["a","b"],["c","d"]]
  • For context.filterActive:
    [
    "barney"
    ]
Menu