In order to reach the child nodes you need to pass the context in the request. In the response there will be a context
property you can pass to the next request.
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();");
}
}
The context object contains the conversationID and other data for the service to keep track of where in the conversation the user is.
"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: The data model seems to have updated. resp.context.system.dialog_stack should not be an array of strings. It should be an array of RuntimeDialogStack objects.
[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: Looks like I've been testing with mismatching version strings. Please try this data model and ensure the version param is 2017-02-03
in the VisualRecognition data model.
[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;}
}