子ノードに到達するには、要求のコンテキストを渡す必要があります。応答では、次のリクエストに渡すことができるcontext
プロパティがあります。
Conversation m_Conversation = new Conversation();
private void SendInitalMessage(string input)
{
if (string.IsNullOrEmpty(input))
throw new ArgumentNullException("input");
// Send inital message to the service
m_Conversation.Message(OnInitalMessage, <workspace-id>, input);
}
private void OnInitalMessage(MessageResponse resp, string customData)
{
if (resp != null)
{
// Check response here
// Create a message request object with the context
MessageRequest messageRequest = new MessageRequest();
messageRequest.InputText = <input-text>;
messageRequest.alternate_intents = true;
messageRequest.ContextData = resp.context; // Context of the conversation
// Send the second message
SendFollowupMessage(messageRequest);
}
else
{
Debug.Log("Message Only: Failed to invoke Message();");
}
}
private void SendFollowupMessage(MessageRequest messageRequest)
{
if (messageRequest == null)
throw new ArgumentNullException("messageRequest");
m_Conversation.Message(OnFollowupMessage, <workspace-id>, messageRequest);
}
private void OnFollowupMessage(MessageResponse resp, string customData)
{
if (resp != null)
{
// Check response here
}
else
{
Debug.Log("Full Request: Failed to invoke Message();");
}
}
コンテキストオブジェクトには、会話内のどこにユーザがいるかを追跡するためのconversationIDとその他のデータが含まれています。
"context": {
"conversation_id": "<conversation-id>",
"system": {
"dialog_stack": [
{
"dialog_node": "<dialog-node>"
}
],
"dialog_turn_counter": <turn-counter>,
"dialog_request_counter": <request-counter>,
"branch_exited": <branch-exited>,
"branch_exited_reason": "<exited-reason>"
},
"defaultCounter": <default-counter>
}
EDIT:データモデルが更新されたようです。 resp.context.system.dialog_stackは文字列の配列であってはなりません。 RuntimeDialogStackオブジェクトの配列でなければなりません。
[fsObject]
SystemResponse
{
public RuntimeDialogStack[] dialog_stack {get;set;}
public int dialog_turn_counter {get;set;}
public int dialog_request_counter {get;set;}
}
[fsObject]
public class RuntimeDialogStack
{
public string dialog_node {get;set;}
public bool invoked_subdialog {get;set;}
}
EDIT 2:バージョン文字列の不一致でテストしたようです。このデータモデルを試して、VisualRecognitionデータモデルのバージョンパラメータが2017-02-03
であることを確認してください。
[fsObject]
SystemResponse
{
public DialogNode[] dialog_stack {get;set;}
public int dialog_turn_counter {get;set;}
public int dialog_request_counter {get;set;}
}
[fsObject]
DialogNode
{
public string dialog_node {get;set;}
public bool invoked_subdialog {get;set;}
}
出典
2017-03-24 16:15:07
taj
は同様の質問、http://stackoverflow.com/questions/42180038/slack-app-watson-watson-looses-intent-from-previous-message-received?rq=1 – Ghettokon
「私が作ったのが見つかりましたSlackのuser_idでグループ化された既存のコンテキストを保存するシンプルなコードこのuser_idのコンテキストがすでに存在する場合、私のアプリケーションはWatson APIを呼び出してこのコンテキストを要求に追加するため、Watsonはこの新しいUserの入力が1。"私たちは実際にC#Unityでこれをどのように認識していますか? – Ghettokon