In Watson Assistant 2018-07-10, you can specify "Option" etc. as the response type. "Option" is like a radio button in HTML, and it is a function that allows you to easily create choices such as three choices and four choices.
What if I call it from the Watson API Java SDK? I tried. In conclusion, it seems that the SDK at the time of writing is not yet compatible with new features. Previously it was returned as text [], but it seems to be returned as generic. It looks like we need to parse the raw JSON.
■ Image

■ Reference (At the time of writing, it cannot be read unless "English" is set from the bottom of the page)
https://console.bluemix.net/docs/services/conversation/release-notes.html#12July2018
■API Document
https://www.ibm.com/watson/developercloud/assistant/api/v1/curl.html?curl#versioning
■ Code
		String version = "2018-07-10";
		String username = "xxx";
		String password = "xxx";
		String workspaceId = "xxx";
		Assistant service = new Assistant(version);
		service.setUsernameAndPassword(username, password);
		InputData input = new InputData.Builder("Hi").build();
		// MessageOptions options = new
		// MessageOptions.Builder(workspaceId).input(input).build();
		MessageOptions options = new MessageOptions.Builder(workspaceId).build();
		// sync
		MessageResponse response = service.message(options).execute();
		System.err.println(response);
		System.err.println("---");
		System.err.println(response.getOutput().getText());
■ Results
{
  "output": {
    "generic": [
      {
        "title": "",
        "options": [
          {
            "label": "Value1",
            "value": {
              "input": {
                "text": "value1"
              }
            }
          },
          {
            "label": "Value2",
            "value": {
              "input": {
                "text": "value2"
              }
            }
          },
          {
            "label": "Value3",
            "value": {
              "input": {
                "text": "value3"
              }
            }
          }
        ],
        "response_type": "option"
      }
    ],
    "text": [],
    "nodes_visited": [
      "Welcome"
    ],
    "log_messages": []
  },
  "input": {},
  "intents": [],
  "entities": [],
  "context": {
    "conversation_id": "xxx",
    "system": {
      "dialog_stack": [
        {
          "dialog_node": "root"
        }
      ],
      "dialog_turn_counter": 1.0,
      "dialog_request_counter": 1.0,
      "branch_exited": true,
      "branch_exited_reason": "completed"
    }
  }
}
---
[]
Recommended Posts