0

How can I connect watson conversation to my webapp(github) using liberty.java? Can someone give me the detailed coding please. Right now I have this:

public class Conversation {
    ConversationService service = new ConversationService("2016-12-06");
service.setUsernameAndPassword("uname","pass");
    MessageRequest newMessage = new MessageRequest.Builder().inputText("Hi").build();

    String workspaceId = "wsId";

    MessageResponse response = service.message(workspaceId, newMessage).execute();
System.out.println(response);

}
ralphearle
  • 1,696
  • 13
  • 18
Sha Queen
  • 29
  • 6

2 Answers2

1

You can see an existing SDK in Java where you create an example with the Watson conversation and Retrieve and Rank Service here:

Link Github: Project Java Conversation Link Github (NodeJS): Project Node JS

In the 2 examples have one conversation and you can modify what you want.

More information, documentation here: Link: Java example SDK Link: Node JS

If you want to use only Conversation in the SDK Java, you can comment the lines of ProxyResource.java from #125, that will force the app to never call R&R and always return the Conversation response.

Sayuri Mizuguchi
  • 5,250
  • 3
  • 26
  • 53
  • how do I display it in html? – Sha Queen Dec 08 '16 at 07:49
  • In that case, you can use simple conversation in the link I've edited now. This SDK is in Node.js and you can also modify what you want, in my case I found it simpler since I make my changes in the index.html that is inside the Public folder. – Sayuri Mizuguchi Dec 08 '16 at 11:41
0

I can work on a little proof of concept for you on the weekend, but basically, the usual way you'll need are these steps:

  1. Use the web UI to create the conversation backend, providing the logical paths of your conversation

  2. In the Liberty runtime, use Watson Java SDK as the middleware between your chat interface and the conversation backend. I suggest you to use Bluemix integration with GIT and DevOps for that

  3. In the frontend, you need some chat interface. Nowadays, the most popular chat interface are mobile platforms, and then you have lots of options, and I suggest you to try Telegram. But of course, you can code your own chat window using servlet+sessions or any other technology you're comfortable with (I myself like Primefaces+JSF since they already have a "console" component for that)

Another popular approach is to use Node-Red instead of the Liberty runtime, since it's easy to integrate and to prototype. About this approach, a simple google search will return lots of links, but this one seems to be a good starting point -- https://www.ibm.com/developerworks/community/blogs/hickmat/entry/Telegram_frontend_for_Watson_using_NodeRED?lang=en

About Liberty+GIT+DevOps, I recommend this tutorial -- https://developer.ibm.com/recipes/tutorials/bluemix-watson-apis-quickstart-using-java-sdk-version-2016/

Leo
  • 751
  • 4
  • 29
  • I am actually using Java Cloudant Web Starter, Node red is not appropriate for me. I just need help with the connection(watson conversation) & display it in html. @Leo – Sha Queen Dec 10 '16 at 09:45
  • I've sent you an email with some code, pls take a look and tell me if it helps. good luck – Leo Dec 13 '16 at 02:56
  • I was asked by my superior not to use Cloudant. Will I be able to connect Watson Conversation to phpmyadmin? Is it possible? – Sha Queen Dec 16 '16 at 06:30
  • I am not sure but I think Watson Conversation does not need any explicit storage, I think the component stores its entities internally – Leo Dec 19 '16 at 13:33