GETTING STARTED
Kore.ai XO Platform
Virtual Assistants Overview
Natural Language Processing (NLP)
Concepts and Terminology
Quick Start Guide
Accessing the Platform
Working with the Builder
Building a Virtual Assistant
Using Workspaces
Release Notes
Current Version
Previous Versions
Deprecations

CONCEPTS
Design
Storyboard
Dialog Tasks
Overview
Dialog Builder
Node Types
Intent Node
Dialog Node
Entity Node
Form Node
Confirmation Node
Message Nodes
Logic Node
Bot Action Node
Service Node
Webhook Node
Script Node
Group Node
Agent Transfer
User Prompts
Voice Call Properties
Dialog Task Management
Connections & Transitions
Component Transition
Context Object
Event Handlers
Knowledge Graph
Introduction
Knowledge Extraction
Build Knowledge Graph
Add Knowledge Graph to Bot
Create the Graph
Build Knowledge Graph
Add FAQs
Run a Task
Build FAQs from an Existing Source
Traits, Synonyms, and Stop Words
Manage Variable Namespaces
Update
Move Question and Answers Between Nodes
Edit and Delete Terms
Edit Questions and Responses
Knowledge Graph Training
Knowledge Graph Analysis
Knowledge Graph Import and Export
Importing Knowledge Graph
Exporting Knowledge Graph
Creating a Knowledge Graph
From a CSV File
From a JSON file
Auto-Generate Knowledge Graph
Alert Tasks
Small Talk
Digital Skills
Digital Forms
Views
Introduction
Panels
Widgets
Train
Introduction
ML Engine
Introduction
Model Validation
FM Engine
KG Engine
Traits Engine
Ranking and Resolver
NLP Configurations
NLP Guidelines
Intelligence
Introduction
Contextual Memory
Contextual Intents
Interruption Management
Multi-intent Detection
Amending Entities
Default Conversations
Sentinment Management
Tone Analysis
Test & Debug
Talk to Bot
Utterence Testing
Batch Testing
Conversation Testing
Deploy
Channels
Publish
Analyze
Introduction
Conversations Dashboard
Performance Dashboard
Custom Dashboards
Introduction
Meta Tags
Dashboards and Widgets
Conversation Flows
NLP Metrics
Containment Metrics
Usage Metrics
Smart Bots
Universal Bots
Introduction
Universal Bot Definition
Universal Bot Creation
Training a Universal Bot
Universal Bot Customizations
Enabling Languages
Store
Manage Assistant
Plan & Usage
Overview
Usage Plans
Support Plans
Invoices
Authorization
Multilingual Virtual Assistants
Masking PII Details
Variables
IVR Settings
General Settings
Assistant Management
Data Table
Table Views
App Definitions
Sharing Data Tables or Views

HOW TOs
Build a Flight Status 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
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
Web SDK Tutorial
Widget SDK Tutorial
Analyze the Assistant
Create a Custom Dashboard
Use Custom Meta Tags in Filters

APIs & SDKs
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

ADMINISTRATION
Introduction
Assistant Admin Console
Administration Dashboard
User Management
Add Users
Manage Groups
Manage Roles
Assistant Management
Enrollment
Invite Users
Send Bulk Invites
Import User Data
Synchronize Users from AD
Security & Compliance
Using Single-Sign On
Security Settings
Cloud Connector
Analytics
Billing
  1. Home
  2. Docs
  3. Virtual Assistants
  4. Builder
  5. Dialog Task
  6. Context Object

Context Object

The Context object is the container object that persists data for dialog execution and across all intents i.e. dialog tasks, action, alert & info tasks, and FAQs. Kore.ai’s natural language processing (NLP) engine populates the intent identified, entities extracted, and history into this object. Keys from the Context object are used in the dialog task and intent transition conditions. Also, the context object can be accessed with additional system and session variables. 

The syntax when using an Context object key in a URL is to enclose the object name in double brackets as shown next:
https://quora.com/{{context.entities.topic}}/rss

The Context object can also be referenced in a script node as well as for dynamic values in an entity node and passed in the payload response to the Kore.ai SDK. You can update the Context object key values based on business logic to influence the dialog task execution.

The platform also creates and maintains Session Variables which can be referred to from here.

The following table describes the Context object keys. These can be classified into Global and Dialog contexts based on when they are created and populated. Refer here for details.

Key Category Description Usage Example
intent Dialog The intent recognized by the NLP interpreter. Syntax: context.intent.<< intent name >>
entities Dialog An array of key/value pairs based on user prompts and recognized user input for those prompts. Syntax: context.entities.<< entity name >>In the following code example, the context.entities object is used to access values for the amount and account names as a confirmation for a funds transfer between accounts

var today = new Date();
if(today.getHours() < 21)
 {
   print("You have requested to transfer " +context.entities.Amount + 
         " USD from " +context.entities.FromAccountName +
         " to " +context.entities.ToAccountName + " account. " +  
         " Your funds will be shown immediately though transfer will be shown in tomorrow's date in your transaction history. Shall I go ahead? ");
  }
 else
 {
  print("You have requested to transfer " +context.entities.Amount + 
        " USD from " +context.entities.FromAccountName +
        " to " +context.entities.ToAccountName + " account. Shall I go ahead? " +
         context.accdata[0].transactions.length);
  }
traits Dialog Traits set for the given context
currentLanguage
(introduced in ver7.1)
Global the current conversation language
suggestedLanguages
(introduced in ver7.1)
Global list of all languages detected by the platform from the user’s first utterance, presented in the order of confidence level. This will be reset at the start of each conversation.
history Global An array that contains the nodeId for each component using the NLP interpreter. An array of objects defining the sequential and historical node path executed in the dialog flow.

  • nodeId – The dialog task flow ID for this node using node type and incremental numbering, for example, intent0, service2, and so forth.
  • state – The status of the object for the timestamp indicated. One of:
    • processing – The Bots Platform begins processing of the node
    • processed – The node and node connections are processed, the following node is found but the dialog has not yet moved to that node.
    • waitingForUserInput – The user was prompted for input but has not been received.
    • pause – The current dialog task is paused while another task is started.
    • resume – The current dialog with the status of pause continues at the same point in the flow after the completion of another task that was started.
    • waitingForServerResponse – The server request is pending an asynchronous response.
    • error – An error occurred, for example, the loop limit is reached, a server or script node execution fails.
    • end –  The dialog reached the end of the dialog flow.
  • type – The type of dialog task. One of:
    • intent – The dialog task is a user intent or task.
    • faq – The dialog task is a knowledge graph.
  • componentName – The name of the node.
  • timestamp – The JSON date timestamp of the node execution, for example, 1492794646000.
onHoldTasks Dialog an array of all tasks that are kept on hold while a conversation is in progress. This is a read-only list that you can use for evaluation purposes. (introduced in ver 7.1)
service node name Dialog A collection of objects for Service node executions.
  • response – Returns the request status and response body as a JSON payload.
    • statusCode – The HTTP status code of the request, for example, 200 OK.
    • body – The JSON payload response body from the service request.
resultsFound Dialog True, if results are returned
message_tone Global An array of recognized tone emotions and scores for the current node in a dialog task.
  • tone_name – The name of the tone detected. One of:
    • angry
    • disgust
    • fear
    • sad
    • joy
    • positive – A special tone used to evaluate the general positivity of an utterance.
  • count
  • level – The level of the tone emotion ranging from -3 to +3. One of:
    • +3 – The user definitely expressed the tone emotion.
    • +2 – The user expressed the tone emotion.
    • +1 – The user likely expressed the tone emotion.
    • 0 – The user tone emotion is neutral.
    • -1 – The user likely suppressed the tone emotion.
    • -2 – The user suppressed the tone emotion.
    • -3 –  The user definitely suppressed the tone emotion.
dialog_tone Global An array of average recognized tone emotions and scores for the entire dialog task session.
  • tone_name – The name of the tone detected. One of:
    • angry
    • disgust
    • fear
    • sad
    • joy
    • positive – A special tone used to evaluate the general positivity of an utterance.
  • count
  • level – The level of the tone emotion ranging from -3 to +3. One of:
    • +3 – The user definitely expressed the tone emotion.
    • +2 – The user expressed the tone emotion.
    • +1 – The user likely expressed the tone emotion.
    • 0 – The user tone emotion is neutral.
    • -1 – The user likely suppressed the tone emotion.
    • -2 – The user suppressed the tone emotion.
    • -3 –  The user definitely suppressed the tone emotion.
<< nodename >>.response.body Dialog The HTTP JSON response from the Service node. Syntax: context.<< node name >>.response.body
In the following code example, the response from a Service node is displayed to the end-user in a Message node.

print(JSON.stringify(context.fetchopportunitiesnode.response.body));
Developer Defined Key Dialog A key/value pair defined by the developer. Syntax: context.<< varName >>
For example, context.customerId

Sample Context Object

The following is a payload response that contains a context object:

"context":{
   "bot":"Kore Banking Documentation",
   "botid":"st-b4a22e86-XXXX-575c-b888-e106d083a251",
   "taskid":"dg-df510618-XXXX-5a0b-8370-ee042b3e5b47",
   "intent":"Agent",
   "intentType":"dialog",
   "entities":{
      "Name":12345,
      "number":1234
   },
   "userInputs":{
      "originalInput":{
         "sentence":" agent",
         "timestamp":1501244143000
      }
   },
   "history":[
      {
         "originalSentence":"agent",
         "timestamp":1501244143000
      },
      {
         "dialogState":"started",
         "timestamp":1501244143000
      },
      {
         "nodeId":"intent0",
         "state":"processed",
         "type":"intent",
         "componentName":"Agent",
         "timestamp":1501244143000
      },
      {
         "nodeId":"entity1",
         "state":"processing",
         "type":"entity",
         "componentName":"Name",
         "timestamp":1501244143000
      },
      {
         "nodeId":"entity1",
         "state":"waitingForUserInput",
         "type":"entity",
         "componentName":"Name",
         "timestamp":1501244143000
      },
      {
         "nodeId":"entity1",
         "state":"processed",
         "type":"entity",
         "componentName":"Name",
         "timestamp":1501244149000
      },
      {
         "nodeId":"entity4",
         "state":"processing",
         "type":"entity",
         "componentName":"number",
         "timestamp":1501244149000
      },
      {
         "nodeId":"entity4",
         "state":"waitingForUserInput",
         "type":"entity",
         "componentName":"number",
         "timestamp":1501244149000
      },
      {
         "nodeId":"entity4",
         "state":"processed",
         "type":"entity",
         "componentName":"number",
         "timestamp":1501244156000
      },
      {
         "nodeId":"agentTransfer3",
         "state":"processing",
         "type":"agentTransfer",
         "componentName":"agenttransfer",
         "timestamp":1501244156000
      },
      {
         "dialogState":"transferredToAgent",
         "timestamp":1501244156000
      }
   ],
   "dialog_tone":[
      {
         "tone_name":"positive",
         "level":1
      }
   ],
   "message_tone":[
      {
         "tone_name":"positive",
         "level":1
      }
   ],
  "currentTags": {
    "tags": [
      "name"
    ]
  },
  "historicTags": [
    {
      "tags": [
        "name"
      ]
    }
  ],
   "session":{
      "EnterpriseContext":{
         "5":"500",
         "TestData-Ent":"1000234",
         "ec1":"Enterprise Context session variable from processor",
         "Enterprise_G_Smith_Email":"george.smith@kore.com",
         "enterprisesessiondialog":"enterprisesessiondialogvalue",
         "enterprisecustomprocessor":"enterprisecustomprocessorvalue",
         "enterprisepreprocessor":"enterprisepreprocessorvalue",
         "EnterpriseContext":"EnterpriseContextvalueresponse",
         "Entersession123":"Entersession123value",
         "EnterpriseContext Summary":"TestingSpread",
         "enterprisecontext":"enterprisecontextvalue",
         "ec2":"Enterprise Context session variable from channel response",
         "EC":"ec session variable from intializer",
         "enterprisepreprocessorkey":"enterprisepreprocessorvalue"
      },
      "BotContext":{
      },
      "UserContext":{
         "profColour":"#3651fc",
         "workinghours":{
            "workdays":"Mon, Tue, Wed, Thu, Fri, Sat, Sun",
            "workstart":"12:00 AM",
            "workend":"12:00 PM"
         },
         "dept":"Product Development",
         "jTitle":"Documentation Manager",
         "profImage":"profile.png",
         "activationStatus":"active",
         "emailId":"help.docs@kore.com",
         "firstName":"Help",
         "lastName":"Docs",
         "orgId":"o-b30656ae-XXXX-XXXX-9181-065f7de34be9",
         "_id":"u-4b9f02a3-XXXX-XXXX-b5cc-6df81c0af603",
         "customData":null,
         "identities":[
            {
               "val":"help.docs@kore.com",
               "type":"email"
            },
            {
               "val":"kore/u-4b9f02a3-XXXX-XXXX-b5cc-6df81c0af603",
               "type":"mapped"
            }
         ]
      },
      "UserSession":{
      },
      "BotUserSession":{
         "isReturningUser": true,
         "lastMessage":{
            "channel":"rtm",
            "messagePayload":{
               "clientMessageId":1501244152843,
               "message":{
                  "body":"1234"
               },
               "resourceid":"/bot.message",
               "botInfo":{
                  "chatBot":"Kore Banking Documentation",
                  "taskBotId":"st-b4a22e86-XXXX-XXXX-b888-e106d083a251"
               },
               "client":"botbuilder",
               "meta":{
                  "timezone":"America/New_York",
                  "locale":"en-US"
               },
               "id":1501244152843
            }
         },
     "lastUserMessageTime": "2021-07-12T07:07:17.278Z"
      },
      "opts":{
         "userId":"u-4b9f02a3-XXXX-XXXX-b5cc-6df81c0af603",
         "streamId":"st-b4a22e86-XXXX-XXXX-b888-e106d083a251"
      }
   }
},
"channel":{
   "_id":"dc-5b4a742a-XXXX-XXXX-938f-520912935456",
   "channelInfos":{
      "requestId":"ms-26aae382-XXXX-XXXX-8bf1-a9e076770956",
      "message":"The bot is not accessible via Web / Mobile Client.",
      "body":"1234",
      "client":"botbuilder",
      "handle":{
         "spanId":"8cab2ce2f6aabc47",
         "traceId":"8cab2ce2f6aabc47",
         "taskBotId":"st-b4a22e86-XXXX-XXXX-b888-e106d083a251",
         "clientId":"5a37bf24-XXXX-XXXX-a816-f9602db08149",
         "userId":"u-4b9f02a3-XXXX-XXXX-b5cc-6df81c0af603",
         "handleId":"54e95c2b-XXXX-XXXX-ba6b-384d4166f1b2"
      },
      "botInfo":{
         "taskBotId":"st-b4a22e86-XXXX-XXXX-b888-e106d083a251",
         "chatBot":"Kore Banking Documentation"
      },
      "from":"u-4b9f02a3-3f6f-XXXX-XXXX-6df81c0af603",
      "type":"rtm"
   },
   "__v":0
},
"baseUrl":"https://bots.kore.ai/api/botsdk/stream/st-b4a22e86-XXXX-XXXX-b888-e106d083a251",
"sendUserMessageUrl":"https://bots.kore.ai/api/botsdk/stream/st-b4a22e86-e95b-XXXX-XXXX-e106d083a251/sendUserMessage/1501244156289",
"sendBotMessageUrl":"https://bots.kore.ai/api/botsdk/stream/st-b4a22e86-e95b-XXXX-XXXX-e106d083a251/sendBotMessage/1501244156289"
}

“lastUserMessageTime”: “2021-07-12T07:07:17.278Z”

Menu