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 Tasks
Knowledge Ontology
Building Knowledge Graph
Importing and Exporting Bot Ontology
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
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
  1. Home
  2. Docs
  3. Bots
  4. Bot Building
  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. The Kore.ai’s natural language processing (NLP) engine populates the intent identified, entities extracted, and history into this object. Keys from the Context object can be used in the dialog task and intent transition conditions. In addition, the context object can be accessed with additional system and session variables. 

The syntax when using a 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 following table describes the Context object keys.

Key Description
intent The intent recognized by the NLP interpreter.
Syntax: context.intent.<< intent name >>
entities 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 Traits set for the given context
session.EnterpriseContext A key/value pair defined by the developer. Any Bots developed by that developer can read and modify this key. The data is common for all Bots and all users in an enterprise.
Syntax:
GET – context.session.EnterpriseContext.<< varName >>
PUT – EnterpriseContext.put( << ‘varName’ >>, << value >>, << persistTimeInMinutes >>)
session.BotContext A key/value pair defined by the developer. The data is common for this Bot only and to all users in an enterprise.
Syntax:
GET – context.session.BotContext.<< varName >>
PUT – BotContext.put( << ‘varName’ >>, << value >>, << persistTimeInMinutes >>)
session.UserContext A read-only key/value pair from the Bots Platform that provides all users profile data. This key is not available for Bot definitions but is available as a platform variable.
Syntax:
GET – context.session.UserContext.<< varName >>
session.UserSession A key/value pair defined by the developer. The data is common for all Bots but only for the specified user in an enterprise.
Syntax:
GET – context.session.UserSession.<< varName >>
PUT – UserSession.put( << ‘varName’ >>, << value >>, << persistTimeInMinutes >>)
session.BotUserSession A key/value pair defined by the developer. The data is common for all users but only for the specified Bot in an enterprise.
Syntax:
GET – context.session.BotUserSession.<< varName >>
PUT – BotUserSession.put( << ‘varName’ >>, << value >>, << persistTimeInMinutes >>)
history An array that contains the nodeId for each component using the NLP interpreter.
<< nodename >>.response.body 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 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":{
         "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
            }
         }
      },
      "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"
}

Sample Context Objects

This section contains a series of sample Context objects.
Sample 1

{
  "context": {
    "bot": "ImageTest",
    "botid": "st-59423292-a088-56f3-8bae-4aca93e979bf",
    "taskid": "dg-5e03ef27-2660-560f-a51e-afba56ec8d0f",
    "intent": "PrintHtml",
    "intentType": "dialog",
    "entities": {
      "url": "www.yahoo.com"
    },
    "history": [
      "intent0",
      "entity2",
      "service3",
      "message4"
    ],
    "session": {
      "EnterpriseContext": {
        "Enterprise_J_Doe_Email": "John.Doe@kore.ai",
        "EnterpriseContext Summary": "Testing",
        "enterprisecontext": "enterprisecontextvalue",
        "enterprisepreprocessor": "enterprisepreprocessorvalue",
        "EnterpriseContext": "EnterpriseContextvalueresponse",
        "enterprisecustomprocessor": "enterprisecustomprocessorvalue",
        "enterprisepreprocessorkey": "enterprisepreprocessorvalue",
        "Entersession123": "Entersession123value",
        "enterprisesessiondialog": "enterprisesessiondialogvalue"
      },
      "BotContext": {},
      "UserContext": {
        "_id": "u-c93c649c-078b-52bc-93ee-f825e2ce909b",
        "emailId": "Jane.Doe.com",
        "lastName": "Jane",
        "firstName": "Doe",
        "profImage": "no-avatar",
        "profColour": "#5AA921",
        "activationStatus": "active",
        "jTitle": "",
        "orgId": "o-b30656ae-9be9-5fa2-9181-065f7de34be9",
        "identities": [
          {
            "val": "Jane.Doe.com",
            "type": "email"
          }
        ]
      },
      "UserSession": {},
      "BotUserSession": {},
      "opts": {
        "userId": "u-c93c649c-078b-52bc-93ee-f825e2ce909b",
        "streamId": "st-59423292-a088-56f3-8bae-4aca93e979bf"
      }
    },
    "accountidtouse": null,
    "report": {
      "response": {
        "body": {
          "imageURLS": {
            "vlarge": "https://app.collab.ai/api/getMediaStream/media/f-72247859-68b4-51d0-a9db-c78d2f1cb962.png?e=1485330342&n=7470041802&s=ImpsR2VPODZNUzVFaTVyN3lGd2hXUy9KQ1g4dE5KeXhEOGwybElWTWQ1VTA9Ig$$",
            "small": "https://app.collab.ai/api/getMediaStream/media/f-d16f9842-5f65-5bd0-8442-25b90f919c6f.png?e=1485330342&n=176619407&s=IitsdS9QM2c3Y212Z1o1V0RTTmkrNkppVnVSbnhHaEpDSnN2ZDNtcW5oVkU9Ig$$",
            "large": "https://app.collab.ai/api/getMediaStream/media/f-57f47443-f3fc-5258-b8ed-b55bfa50e63d.png?e=1485330343&n=1981298329&s=IkswUmZmQmJ1Lzc0d09FNi9XYld1T1IyZzAwa3p0M2tuS0g3U0pOZTVUUzg9Ig$$"
          }
        }
      }
    },
    "message_tone": [],
    "dialog_tone": [],
    "mappedIntents": []
  }
}

Sample 2

{
  "context": {
    "bot": "ImageTest",
    "botid": "st-59423292-a088-56f3-8bae-4aca93e979bf",
    "taskid": "dg-5e03ef27-2660-560f-a51e-afba56ec8d0f",
    "intent": "PrintHtml",
    "intentType": "dialog",
    "entities": {
      "url": "www.yahoo.com"
    },
    "history": [
      "intent0",
      "entity2",
      "service3",
      "message4"
    ],
    "session": {
      "EnterpriseContext": {
        "Enterprise_G_Ravindra_Email": "ravindra.balleda@kore.ai",
        "EnterpriseContext Summary": "TestingSpread",
        "enterprisecontext": "enterprisecontextvalue",
        "enterprisepreprocessor": "enterprisepreprocessorvalue",
        "EnterpriseContext": "EnterpriseContextvalueresponse",
        "enterprisecustomprocessor": "enterprisecustomprocessorvalue",
        "enterprisepreprocessorkey": "enterprisepreprocessorvalue",
        "Entersession123": "Entersession123value",
        "enterprisesessiondialog": "enterprisesessiondialogvalue"
      },
      "BotContext": {},
      "UserContext": {
        "_id": "u-c93c649c-078b-52bc-93ee-f825e2ce909b",
        "emailId": "umesh.kushwaha@kore.ai",
        "lastName": "Kushwaha",
        "firstName": "Umesh",
        "profImage": "no-avatar",
        "profColour": "#5AA921",
        "activationStatus": "active",
        "jTitle": "",
        "orgId": "o-b30656ae-9be9-5fa2-9181-065f7de34be9",
        "identities": [
          {
            "val": "umesh.kushwaha@kore.ai",
            "type": "email"
          }
        ]
      },
      "UserSession": {},
      "BotUserSession": {},
      "opts": {
        "userId": "u-c93c649c-078b-52bc-93ee-f825e2ce909b",
        "streamId": "st-59423292-a088-56f3-8bae-4aca93e979bf"
      }
    },
    "accountidtouse": null,
    "reportPage": {
      "response": {
        "body": {
          "imageURLS": {
            "vlarge": "https://bots.kore.ai/api/getMediaStream/media/f-72247859-68b4-51d0-a9db-c78d2f1cb962.png?e=1485330342&n=7470041802&s=ImpsR2VPODZNUzVFaTVyN3lGd2hXUy9KQ1g4dE5KeXhEOGwybElWTWQ1VTA9Ig$$",
            "small": "https://bots.kore.ai/api/getMediaStream/media/f-d16f9842-5f65-5bd0-8442-25b90f919c6f.png?e=1485330342&n=176619407&s=IitsdS9QM2c3Y212Z1o1V0RTTmkrNkppVnVSbnhHaEpDSnN2ZDNtcW5oVkU9Ig$$",
            "large": "https://bots.kore.ai/api/getMediaStream/media/f-57f47443-f3fc-5258-b8ed-b55bfa50e63d.png?e=1485330343&n=1981298329&s=IkswUmZmQmJ1Lzc0d09FNi9XYld1T1IyZzAwa3p0M2tuS0g3U0pOZTVUUzg9Ig$$"
          }
        }
      }
    },
    "message_tone": [],
    "dialog_tone": [],
    "mappedIntents": []
  }
}

The following section describes the Context object parameters.

  • bot – The name of the bot.
  • botid – The system unique GUID for the bot.
  • taskid – The system unique GUID for the dialog task.
  • intent – The name of the root intent of the dialog task.
  • intentType – The dialog task type. One of:
    • dialog
    • ???
  • entities – An array o key/value pairs that represent entity nodes processed and their values, for example, “SourceAirport”:“MCO”.
  • history – 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 object for the timestamp indicated. One of:
      • processing – The Bots Platform begins processing of the node
      • processed – The node and node connections are processed, a 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 status of pause continues at the same point in the flow after 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 in 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 task.
    • componentName – The name of the node.
    • timestamp – The JSON date timestamp of the node execution, for example, 1492794646000.
  • < service node name > – 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.
  • resultsFoundTrue, if results are returned.
  • session – Coming soon.
    • EnterpriseContext – Key/value pairs available to all bots and all users in an enterprise.
    • BotContext – Key/value pairs available to all users of this specific bot.
    • UserContext – Key/value pairs available to all bots for a user.
      • _id – The Kore.ai user ID.
      • emailId – The email address associated with the user ID.
      • lastName – The last name of the user.
      • firstName – The first name of the user.
      • profImage – The image or avatar filename of the user.
      • profColour – The account color for the user.
      • activationStatus – The account status of the user. One of:
        • active – The user is active and can interact with other Kore.ai users.
        • inactive – The user is not active, but user data is retained in the system.
        • suspended – The user is suspended by an administrator. The user cannot log on to Kore.ai, however, messages can still be sent to the suspended user.
        • locked – The user exceeded the maximum number of log on attempts.
      • jTitle – The title of the user, if defined.
      • orgId – The organizational ID of the user account, if defined.
      • customData – Coming soon.
      • identities – Alternate user IDs, if defined.
        • val – The alternate ID
        • type – The type of alternate ID. One of:
          • email
          • More coming soon.
    • UserSession – Key/value pairs that you can define for this specific user for all bots in an enterprise
    • BotUserSession – Key/value pairs that you can define to a specific bot based on the inputs by a specific user.
    • opts – Coming soon with examples.
      • userId
      • streamId
  • message_tone – Coming soon with examples. 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 – Coming soon with examples.
    • 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 – 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 – Coming soon with examples.
    • 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.
Menu