On IBM Watson doc https://www.ibm.com/watson/developercloud/conversation/api/v1/?curl#introduction
I look the only CURL request example. I need the Java request example
Can you help me?
On IBM Watson doc https://www.ibm.com/watson/developercloud/conversation/api/v1/?curl#introduction
I look the only CURL request example. I need the Java request example
Can you help me?
Take a look at the tests available with the SDK.
In particular look at: https://github.com/watson-developer-cloud/java-sdk/blob/develop/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/ConversationServiceIT.java#L90
First, add the Maven dependencies:
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>java-sdk</artifactId>
<version>3.3.1</version>
</dependency>
Compile with Gradle: com.ibm.watson.developer_cloud:java-sdk:3.3.1
And request the Conversation service with the following code:
ConversationService service = new ConversationService(ConversationService.VERSION_DATE_2017_03_02);
service.setUsernameAndPassword("<username>", "<password>");
MessageRequest newMessage = new MessageRequest.Builder().inputText("Hi").build();
MessageResponse response = service.message("<workspace-id>", newMessage).execute();
System.out.println(response);
//Moving from Node 1 to Node 2.
Map<String, Object> context = new HashMap<String, Object>();
// first message
MessageRequest newMessage = new MessageRequest.Builder()
.input(new InputData.Builder("First message").build())
.context(context)
.build();
MessageResponse response = service.message("<workspace-id>", newMessage).execute();
// second message
newMessage = new MessageRequest.Builder()
.input(new InputData.Builder("Second message").build())
.context(response.getContext()) // output context from the first message
.build();
response = service.message("<workspace-id>", newMessage).execute();
System.out.println(response);
See the code inside Java SDK from IBM Developers.
I think you can like this Project with Conversation and Discovery to verify others examples.
The new version of the Watson Assistant (formerly Conversation) API reference documentation includes Java examples: https://console.bluemix.net/apidocs/assistant?language=java