OVERVIEW
Virtual Assistants
Kore.ai Platform
Key Concepts
Natural Language Processing (NLP)
Accessing Platform
VIRTUAL ASSISTANTS
Virtual Assistant Builder
Virtual Assistant Types
Getting Started
Creating a Simple Bot
SKILLS
Storyboard
Dialog Task
Introduction
Dialog Builder (New)
Dialog Builder (Legacy)
User Intent Node
Dialog Node
Entity Node
Supported Entity Types
Composite Entities
Supported Colors
Supported Company Names
Form Node
Logic Node
Message Nodes
Confirmation Nodes
Bot Action Node
Service Node
Custom Authentication
2-way SSL for Service nodes
Script Node
Agent Transfer Node
WebHook Node
Grouping Nodes
Connections & Transitions
Manage Dialogs
User Prompts
Knowledge Graph
Terminology
Building
Generation
Importing and Exporting
Analysis
Knowledge Extraction
Build
Alert Tasks
Introduction
Ignore Words and Field Memory
How to Schedule a Smart Alert
Small Talk
Digital Views
Overview
Configuring Digital Views
Digital Forms
Overview
How to Configure Digital Forms
NATURAL LANGUAGE
Overview
Machine Learning
Introduction
Model Validation
Fundamental Meaning
Introduction
NLP Guidelines
Knowledge Graph
Traits
Introduction
How to Use Traits
Ranking and Resolver
Advanced NLP Configurations
INTELLIGENCE
Overview
Context Management
Overview
Session and Context Variables
Context Object
How to Manage Context Switching
Manage Interruptions
Dialog Management
Sub-Intents & Follow-up Intents
Amend Entity
Multi-Intent Detection
Sentiment Management
Tone Analysis
Sentiment Management
Event Based Bot Actions
Default Conversations
Default Standard Responses
TEST & DEBUG
Talk to Bot
Utterance Testing
Batch Testing
Record Conversations
CHANNELS
PUBLISH
ANALYZE
Overview
Dashboard
Custom Dashboard
Overview
How to Create Custom Dashboard
Conversation Flows
NLP Metrics
ADVANCED TOPICS
Universal Bots
Overview
Defining
Creating
Training
Customizing
Enabling Languages
Store
Smart Bots
Defining
koreUtil Libraries
SETTINGS
Authorization
Language Management
PII Settings
Variables
Functions
IVR Integration
General Settings
Management
Import & Export
Delete
Versioning
Collaborative Development
Plan Management
API GUIDE
API Overview
API List
API Collection
SDKs
SDK Overview
SDK Security
SDK App Registration
Web SDK Tutorial
Message Formatting and Templates
Mobile SDK Push Notification
Widget SDK Tutorial
Widget SDK – Message Formatting and Templates
Web Socket Connect & RTM
Using the BotKit SDK
Installing
Configuring
Events
Functions
BotKit SDK Tutorial – Agent Transfer
BotKit SDK Tutorial – Flight Search Sample Bot
Using an External NLP Engine
ADMINISTRATION
HOW TOs
Creating a Simple Bot
Creating a Banking Bot
Context Switching
Using Traits
Schedule a Smart Alert
Configure UI Forms
Add Form Data into Data Tables
Configuring Digital Views
Add Data to Data Tables
Update Data in Data Tables
Custom Dashboard
Custom Tags to filter Bot Metrics
Patterns for Intents & Entities
Build Knowledge Graph
Global Variables
Content Variables
Using Bot Functions
Configure Agent Transfer
Update Balance Task
Transfer Funds Task
RELEASE NOTES
  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