I'm currently trying to integrate some Java code with a Watson Conversation Dialog. At the moment, I'm using the following code to pass a simple text input to the Watson dialog:
MessageRequest emptyReq = new MessageRequest.Builder().inputText(" ").build();
MessageResponse response1 = service.message(workspaceId, emptyReq).execute();
MessageRequest req1 = new MessageRequest.Builder().inputText("cancel my delivery").context(response1.getContext()).build();
MessageResponse response2 = service.message(workspaceId, req1).execute();
This code works as intended and the response is correct. However, I'm unsure as to how I could pass variables in a message which would then be interpreted by the dialog.
For example, let's say that I store a date in a variable named "estimatedDeliveryDate
".
I would send the message "Cancel my delivery" to Watson, along with estimatedDeliveryDate
so that the dialog would respond with "Your order due on estimatedDeliveryDate
has now been cancelled".
Any help would be greatly appreciated, thanks.
In the Tooling, go to your node, click on the pencil to edit. Then add
"context": {
"estimatedDeliveryDate": "today"
}
Then on the output section you can write:
"output": {
"text": {
"values": [
"Your reservation for <? $estimatedDeliveryDate ?> got canceled"
]
}
Obviously, you can replace today
with a dynamic value captured from the input. For that use @sys-date
. See https://www.ibm.com/watson/developercloud/doc/conversation/system-entities.html