Contextオブジェクトはコンテナオブジェクトで、ダイアログ実行のためのデータを保持し、すべてのインテント(ダイアログタスク、アクション、アラート&情報タスク、FAQなど)に渡ってデータを保持します。Kore.ai の自然言語処理(NLP)エンジンは、識別されたインテント、抽出されたエンティティ、履歴をこのオブジェクトに入力します。Contextオブジェクトからのキーは、ダイアログタスクとインテントの遷移条件で使用することができます。さらに、Contextオブジェクトは、追加のシステム変数やセッション変数でアクセスすることができます。
URLでContextオブジェクトキーを使用する場合の構文は、次のようにオブジェクト名を二重括弧で囲みます:
https://quora.com/{{context.entities.topic}}/rss
Contextオブジェクトは、エンティティノードの動的な値と同様にスクリプトノードでも参照することができ、Kore.ai SDKへのペイロードレスポンスで渡すことができます。ビジネスロジックに基づいてContextオブジェクトのキー値を更新し、ダイアログタスクの実行に影響を与えることができます。
以下の表では、Contextオブジェクトキーについて説明します。
| キー | 説明 |
|---|---|
| intent | NLPインタプリタが認識したインテント。 Syntax: context.intent.<< intent name >> |
| エンティティ | ユーザーのプロンプトと、それらのプロンプトに対する認識されたユーザー入力に基づいたキー/値のペアの配列。 構文: context.entities.<< entity name >>次のコード例では、context.entitiesオブジェクトは、口座間の資金移動の確認として、金額と口座名の値にアクセスするために使用されます。
var today = new Date();
if(today.getHours() < 21)
{
print(”あなたは振り込みを要求しました”」+context.entities.Amount + " USD from " +context.entities.FromAccountName +" to " +context.entities.ToAccountName + " account. " + ”振込は明日の日付で 取引履歴に表示されますが、資金はすぐに表示されます。 先へ進んでもいいですか?”);
}
else
{
print("あなたは振り込みを要求しました" +context.entities.Amount + " USD from " +context.entities.FromAccountName +" to " +context.entities.ToAccountName + " account. 先へ進んでもいいですか? " +context.accdata[0].transactions.length);
}
|
| traits | 指定されたコンテキストに設定された特性 |
| currentLanguage (introduced in ver7.1) |
現行の会話言語 |
| suggestedLanguages (introduced in ver7.1) |
ユーザーの最初の発言からプラットフォームが検出したすべての言語のリストを、信頼度の高い順に表示します。これは各会話の開始時にリセットされます。 |
| session.EnterpriseContext | 開発者によって定義されたキー/値のペア。その開発者によって開発されたボットは、このキーを読み取って変更することができます。このデータは、企業内のすべてのボットとすべてのユーザーに共通です。 構文: GET – context.session.EnterpriseContext.<< varName >>PUT – EnterpriseContext.put( << ‘varName’ >>, << value >>, << persistTimeInMinutes >>)DELETE – EnterpriseContext.delete( << ‘varName’ >>) |
| session.BotContext | 開発者によって定義されたキー/値のペア。データは、このボットのみに共通であり、企業内のすべてのユーザーに提供されます。 構文: GET – context.session.BotContext.<< varName >>PUT – BotContext.put( << ‘varName’ >>, << value >>, << persistTimeInMinutes >>)DELETE – BotContext.delete( << ‘varName’ >>) |
| session.UserContext | すべてのユーザーのプロファイルデータを提供するボットプラットフォームの読み取り専用キー/値のペア。このキーはボット定義では使用できませんが、プラットフォーム変数として使用できます。 Syntax: GET – context.session.UserContext.<< varName >> |
| session.UserSession | 開発者によって定義されたキー/値のペア。データはすべてのボットに共通ですが、企業内の指定されたユーザーにのみ適用されます。 構文: GET – context.session.UserSession.<< varName >>PUT – UserSession.put( << ‘varName’ >>, << value >>, << persistTimeInMinutes >>)DELETE – UserSession.delete( << ‘varName’ >>) |
| session.BotUserSession | 開発者によって定義されたキー/値のペア。データはすべてのユーザーに共通ですが、企業内の指定されたボットにのみ適用されます。 構文: GET – context.session.BotUserSession.<< varName >>PUT – BotUserSession.put( << ‘varName’ >>, << value >>, << persistTimeInMinutes >>)DELETE – BotUserSession.delete( << ‘varName’ >>) |
| 履歴 | NLP インタプリタを用いた各コンポーネントのnodeIdを含む配列。 |
| << nodename >>.response.body | サービスノードからのHTTP JSON応答。 構文: context.<< node name >>.response.body次のコード例では、サービスノードからの応答が メッセージノードでエンドユーザーに表示されます。 |
| 開発者定義キー | 開発者が定義したキー/値のペア。 構文: context.<< varName >>For example, 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":{
"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"
}
サンプルコンテキストオブジェクト
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": []
}
}
次のセクションでは、コンテキストオブジェクトのパラメーターについて説明します。
bot– ボットの名前。botid– ボットのシステム固有のGUID。taskid– ダイアログタスクのシステム固有の GUID。intent– ダイアログタスクのルートインテントの名前。intentType– ダイアログタスクのタイプのうち、次のいずれか一つ:entities– 処理されたエンティティノードとその値を表すキー/値のペアの配列。例えば、“SourceAirport”:“MCO”.history– ダイアログフローで実行されるシーケンシャルノードパスとヒストリカルノードパスを定義するオブジェクトの配列。nodeId– このノードのダイアログタスクフロー IDは、ノードタイプとインクリメンタルナンバリングを使用して、例えば、intent0、service2などのようになります。state– 表示されたタイムスタンプに対するオブジェクトのステータスのうち、次のいずれか一つ:– ボットプラットフォームは、ノードの処理を開始します。processing– ノードとノードの接続が処理され、次のノードが見つかりましたが、ダイアログはまだそのノードに移動していません。processed– 入力を求められましたが、受信していません。waitingForUserInput– 別のタスクが開始されている間、現在のダイアログタスクは一時停止されます。pause– 一時停止のステータスを持つ現在のダイアログは、開始された別のタスクが完了した後も、フロー内の同じポイントで継続しています。resume– サーバーリクエストは非同期応答を保留しています。waitingForServerResponse– ループ制限に達した、サーバーやスクリプトノードの実行に失敗したなどのエラーが発生しました。error– ダイアログが、ダイアログフローの最後に到着しました。end
type– ダイアログタスクタイプのうち、次のいずれか一つ:intent– ダイアログタスクは、ユーザーの意図やタスクです。faq– ダイアログタスクはナレッジグラフです。
componentName– ノードの名前。timestamp– ノード実行時のJSON 日付のタイムスタンプ、例えば、 1492794646000。
onHoldTasks– 会話の進行中に保留されているすべてのタスクの配列。これは読み取り専用のリストで、評価のために使うことができます。(ver 7.1 で導入)< サービスノード名 >– サービスノードを実行するためのオブジェクトのコレクション。response– リクエストステータスとレスポンス本文をJSONペイロードとして返します。statusCode– リクエストのHTTPステータスコード、例えば、200 OK。body– サービスリクエストからのJSONペイロード応答本文。
resultsFound– 結果が返された場合、Trueとなります。sessionEnterpriseContext– 企業内のすべてのボットとすべてのユーザーが利用できるキー/値のペア。BotContext– この特定のボットのすべてのユーザーが利用できるキー/値のペア。UserContext– ユーザーのすべてのボットで利用可能なキー/値のペア。_id– Kore.aiユーザーID。emailId– ユーザーIDに関連付けられたメールアドレス。lastName– ユーザーの姓。firstName– ユーザーのファーストネーム。profImage– ユーザーの画像またはアバターのファイル名。profColour– ユーザーのアカウントカラー。activationStatus– ユーザーのアカウントのステータスのうち、次のいずれか一つ:active– ユーザーはアクティブであり、他の Kore.ai ユーザーと交流することができます。inactive– ユーザーはアクティブではありませんが、ユーザーデータはシステムに保持されています。suspended– ユーザーは管理者により一時停止されています。ユーザーはKore.aiにログオンすることはできませんが、利用停止されたユーザーにメッセージを送信することはできます。locked– ユーザーがログオン試行回数の上限を超えました。
jTitle– 定義されている場合は、ユーザーのタイトル。orgId– 定義されている場合は、ユーザーアカウントの組織 ID。customData– – これを使用して、Webチャネルにユーザー情報を送信します。現在はWebSDKのみです。 詳細についてはこちらをご確認ください。identities– 定義されている場合は、代替のユーザーID。val– 代替の IDtype– 代替 ID のタイプ。
UserSession– 企業内のすべてのボットに対して、この特定のユーザーに対して定義できるキー/値のペアBotUserSession– 特定のユーザーの入力に基づいて、特定のボットに定義できるキー/値のペアです。optsuserId– Kore.aiに割り当てられたユーザーIDstreamId– ボットID
message_toneダイアログタスクの現在のノードの認識された感情のトーンとスコアの配列。tone_name– 検出されたトーンの名称のうち、次のいずれか一つ:angrydisgustfearsadjoypositive– 発言の一般的な肯定性を評価するために使用される特別なトーン。
countlevel– 感情のトーンのレベル-3から+3のうち、次のいずれか一つ:- +3 – ユーザーは間違いなく感情のトーンを表現していました。
- +2 – ユーザーは感情のトーンを表現しました。
- +1 – ユーザーは感情のトーンを表現している可能性が高い。
- 0 – ユーザーの感情のトーンはニュートラルです。
- -1 – ユーザーは感情のトーンを表現しました。
- -2 – ユーザーは感情のトーンを抑えていました。
- -3 – ユーザーは間違いなく感情のトーンを抑えていました。
dialog_tone– ダイアログタスクセッション全体の平均的な認識された感情のトーンとスコアの配列。tone_name– 検出されたトーンの名称のうち、次のいずれか一つ:angrydisgustfearsadjoypositive– 発言の一般的な肯定性を評価するために使用される特別なトーン。
countlevel– 感情のトーンのレベル-3から+3までのうち、次のいずれか一つ:- +3 – ユーザーは間違いなく感情のトーンを表現していました。
- +2 – ユーザーは感情のトーンを表現していました。
- +1 – ユーザーは感情のトーンを表現した可能性が高い。
- 0 – ユーザーの感情のトーンはニュートラルです。
- -1 – ユーザーは感情のトーンを抑えていた可能性が高い。
- -2 – ユーザーは感情のトーンを抑えていました。
- -3 – ユーザーは間違いなく感情のトーンを抑えていました。
