Contextオブジェクトは、ダイアログ実行のためのデータおよびすべてのインテント(ダイアログタスク、アクション、アラートと情報タスク、およびFAQ)にわたって保持するコンテナオブジェクトです。Kore.aiの自然言語処理(NLP)エンジンは、特定されたインテント、抽出されたエンティティ、および履歴をこのオブジェクトに入力します。Contextオブジェクトのキーは、ダイアログタスクとインテントの遷移条件において使用されます。また、contextオブジェクトには、システム変数およびセッション変数を追加してアクセスすることができます。 Context のオブジェクトキーをURLで使用するときの構文は、次のようにオブジェクト名を二重括弧で囲みます。https://quora.com/{{context.entities.topic}}/rss  Context オブジェクトは、エンティティノードの動的な値と同様に、スクリプトノードでも参照でき、Kore.ai SDKへのペイロード応答に渡すことができます。ダイアログタスクの実行に影響を与えるために、ビジネスロジックに基づいて Context オブジェクトのキー値を更新することができます。このプラットフォームは、セッション変数も作成および管理しており、それは、こちらから参照できます。
次の表では、Contextのオブジェクトキーについて説明します。これらは、作成された時期と入力された時期に基づき、グローバルコンテキストとダイアログコンテキストに分類されています。詳細はこちらをご参照ください。
| キー | カテゴリ | 説明 | 使用例 | 
|---|---|---|---|
| インテント | ダイアログ | NLPインタプリターが認識するインテント。 | 構文: context.intent.<< intent name >> | 
| エンティティ | ダイアログ | ユーザープロンプトと、そのプロンプトに対して認識されたユーザー入力に基づくキー/値ペアの配列。 | 
 構文: 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);
  }
 | 
| 特性 | ダイアログ | 指定されたコンテキストに設定された特性 | |
| currentLanguage (introduced in ver7.1) | グローバル | 現在の会話言語 | |
| suggestedLanguages (introduced in ver7.1) | グローバル | ユーザーの最初の発話からプラットフォームが検出したすべての言語のリスト、信頼度の高い順に表示。これは、各会話の開始時にリセットされます。 | |
| 履歴 | グローバル | NLPインタプリターを使用した各コンポーネントの nodeId を含む配列。 | 
 ダイアログフローにおいて実行される順次的、履歴的なノードパスを定義するオブジェクトの配列。 
  | 
| onHoldTasks | ダイアログ | 会話の進行中に保留されているすべてのタスクの配列。これは、評価目的で使用できる読み取り専用のリストです。(Ver 7.1で導入) | |
| サービスノード名 | ダイアログ | サービスノード実行用のオブジェクトのコレクションです。 | 
  | 
| resultsFound | ダイアログ | 結果が返ってくる場合は、true | |
| message_tone | グローバル | ダイアログタスクの現在のノードで認識された口調の喜怒哀楽とスコアの配列。 | 
  | 
| dialog_tone | グローバル | [ダイアログタスク]セッション全体の平均的な認識された口調の喜怒哀楽とスコアの配列。 | 
  | 
| << nodename >>.response.body | ダイアログ | サービスノードからのHTTP JSONレ応答。 | 構文: context.<< node name >>.response.body 以下のコード例では、サービスノードからの応答をメッセージがノードでエンドユーザーに表示されています。  | 
| 定義済み開発者のキー | ダイアログ | 開発者が定義したキーと値のペア。 | 構文: context.<< varName >> 例: context.customerId | 
コンテキストオブジェクトの例 コンテキストオブジェクトを含むペイロード応答を以下に示します。
"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”