Please take a look at the images. The response that I am getting on IBM UI side is not showing in the Java console. It is empty or null, but the intent is hit correctly.
I am developing a chatbot using the java watson conversation api, but I am facing an error while hitting the child node. Is it a context issue or something else? I am not able to figure it out. I attached the code.
Please help.
input_gui is user input
MessageRequest newMessage = new
MessageRequest.Builder().inputText(input_gui).context(context).build();
MessageResponse response = conversationService.message(workspaceId, newMessage).execute();
newMessage = new MessageRequest.Builder()
.inputText(input_gui)
.context(response.getContext()) // output context from the first message
.build();
System.out.println("watson response"+response);
Please look at image i am attaching. This image is .......
Here is working code I got my error I called service credential every time so context get initialize on every input message that why I am not able to get single conversation id in conversation now it's working
MessageRequest newMessage = new MessageRequest.Builder().inputText(input).context(context).build();
MessageResponse response = service.message(WORKSPACE_ID,newMessage).execute();
context = response.getContext();
System.out.println(response);
I'm not one expert in Java but, trying to help you, check the Java SDK examples for Watson Conversation. You can check out this project from IBM Developers, they are using Conversation Service with Java.
See the code that I did a few months ago for one test:
MessageRequest.Builder messageRequestBuilder = new MessageRequest.Builder();
messageRequestBuilder.inputText(input_gui);
messageRequestBuilder.context(question.context); //this context comes from a previous step
ServiceCall<MessageResponse> response = conversationService.message(workspaceId, messageRequestBuilder.build());
MessageResponse mAnswer = response.execute();
Object textObject = mAnswer.getOutput().get("text");
Related
In node-red in ibm cloud. I am able to use the IBM Watson node "assistant workspace manager" to retrieve a particular dialog node. However, I am unable to use the same "assistant workspace manager" to update a dialog node. I keep getting the error message "Invalid Request Body".
It is not a matter of incorrect credentials, because I use the same credentials for both instances.
Below is the code in my functions module that passes the information to my "assistant workspace manager" node so that it can update a dialog node in my watson conversation workspace.
var uptime = msg.payload[1].d.uptime;
var message = "Server uptime is " + uptime + " seconds.";
msg.topic = "";
msg.dialog_node.output.generic[0].values[0].text = message;
msg.payload = msg.dialog_node;
return msg;
I literally took the dialog node that was returned to me and combined it with the message that had the info I wanted to inject, then modified the payload (before attempting to update my dialog node) so that the payload looked exactly like the dialog node that was returned to me (except with the text for the message modified).
I have successfully done this in the past, by manually formatting the msg.payload object similar to the format that it is returned in. I tried that also, but when that didn't work, I attempted this method.
Any advice would be appreciated.
Thanks in Advance.
This is because the underlying Node.JS SDK for watson-developer-cloud has been updated. https://cloud.ibm.com/apidocs/assistant?code=node#update-dialog-node
The JSON that you supply needs to have at least one field with a new_ prefix as a key.
So in this example the condition is being updated:
{
"type":"standard",
"title":"Entry Point For Up Down Commands",
"output":{},
"context":
{
"appl_action":"increase"
},
"next_step":
{
"behavior":"jump_to",
"selector":"condition",
"dialog_node":"node_11_1467233013716"
},
"new_conditions":"#turn_up",
"dialog_node":"Entry Point For Up Down Commands",
"previous_sibling":"node_1_1487022155950"
}
I need to amend the node info tab with this information.
I have written a plugin wherein I am trying to get an XML response.
This is my code :
// Set the Method property of the request to POST.
string strXMLServer = "xxx";
var request = (HttpWebRequest)WebRequest.Create(strXMLServer);
request.Method = "POST";
// Set the ContentType property of the WebRequest.
request.ContentType = "xyz";
// Assuming XML is stored in strXML
byte[] byteArray = Encoding.UTF8.GetBytes(strXML);
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
//(LINE 5) Get the request stream
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
This code works fine when its written in a console application. But when I copy the same code to a class library(plugin) and tries to debug it using plugin profiler, the application gets stopped abruptly when it reaches (LINE 5)
i.e. At Stream dataStream = request.GetRequestStream();
request.GetRequestStream() function is not working with plugin, but works fine within a console.
Any help would be appreciated :)
Thanks in advance
Note: I am using Dynamics 365 online trial version
There are a couple of things to take into consideration when building a plugin with web requests. Firstly, you need to use WebClient as it's widely supported by Microsoft products.
Secondly, your URL needs to be a DNS name and not an IP address, as this is a hosted plugin in sandbox mode.
Example from Microsoft's website: https://msdn.microsoft.com/en-us/library/gg509030.aspx
Reading material: https://crmbusiness.wordpress.com/2015/02/05/understanding-plugin-sandbox-mode/
Exception thrown: 'System.Net.Http.UnsupportedMediaTypeException' in System.Net.Http.Formatting.dll
Exception thrown: 'System.AggregateException' in mscorlib.dll
Dim serializer As New ManateeSerializer
TrelloConfiguration.Serializer = serializer
TrelloConfiguration.Deserializer = serializer
TrelloConfiguration.JsonFactory = New ManateeFactory()
TrelloConfiguration.RestClientProvider = New WebApiClientProvider()
TrelloAuthorization.Default.AppKey = "[My app key]"
TrelloAuthorization.Default.UserToken = "[my app secret]"
Dim boardId As String = "56425ef7de9eb12872b4a662"
Dim Board As New Board(boardId)
Console.WriteLine(Board)
This is my first step off into accessing Trello via the API so I'm sure I must be missing something important. App compiles fine, and as long as I don't reference the "Board" code executes with no errors.
I'm not real clear what the "boardId" should be? Got it of the JSON example from a card from the Trello API web site?
I was able to solve this by including the following:
TrelloConfiguration.RestClientProvider = New RestSharpClientProvider()
It seems this line of code was missing in the example I copied.
Also for any newbies that end up finding this, my next question was how do I get a user token for use with the API. This answer got me going...
How to get a permanent user token for writes using the Trello API?
I need help, in my custome receiver Chromecast app, I can not fetch media metadata with which the app was initialized.
I loaded media like this, after sucesful session request:
var mediaInfo = new chrome.cast.media.MediaInfo('https://wse-wowaza01.playne.tv:443/webdrmorigin/1042a2W.smil/manifest.mpd');
mediaInfo.customData = {
"userId": "mislav",
"sessionId": "39BE906248F9F5C4A93C7",
"merchant": "playnr"
};
mediaInfo.metadata = new chrome.cast.media.MovieMediaMetadata();
mediaInfo.metadata.metadataType = chrome.cast.media.MetadataType.MOVIE;
var img = new chrome.cast.Image('https://ottservice.playnr.tv/OTTranscoderHttps/get?url=http%asd9.168%2f20664_5b8df65c-67ff-4f13-b90d-b28c37f2310c.jpg&w=224&h=126');
mediaInfo.metadata.images = [img];
mediaInfo.contentType = 'video/mp4';
var request = new chrome.cast.media.LoadRequest(mediaInfo);
//this.playerState = this.PLAYER_STATE.LOADING;
this.session.loadMedia(request,
this.onLoadMediaSuccess.bind(this, 'loadMedia'),
this.onLoadMediaFailure.bind(this)
);
How can i access that metadata in receiver app? I tried with
cast.receiver.MediaManager.getInstance()
but no luck. Are there any steps before need to code on receiver to make data available?
Thank you for help, pointed me in right direction.
Got it working, this was the problem. I am using 3rd party DMR javascript plugin for content protection. It encapsulates cast_receiver and had already instantiated MediaManager & ReceiverManager, i didnt noticed that. Then i instantiated new mediaManager, but it wasn bound to any data. Pause/play event were all handled by plugins mediamanager instance, so my instance was useless. As soon i referenced allready instantiated mediamanager, data is there and his events are working. Same with receiver manager, i started instance that was already started and problems....SO conclusion, i dont need to instantiate any, DRM plugin takes care of everything, just need to override his event handlers
Depends on where on the receiver you want t access that info. For example, in a number of callbacks, you have an "event" of type cast.receiver.MediaManager.Event, from which you can get, for example, a cast.receiver.MediaManager.LoadRequestData object via event.data. Then this data object has your customData (data.customData)
I am using AXIS2 as client for handling SOAP response. The client stubs are generated using WSDL2JAVA command. To solve an issue, I am trying to read an xml response stored in .xml file in the generated stub, and assign to SOAPEnvelope. Below is the code written to load .xml content :
InputStream is = new ByteArrayInputStream((sb.toString()).getBytes());
javax.xml.parsers.DocumentBuilderFactory factory = avax.xml.parsers.DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
javax.xml.parsers.DocumentBuilder builder = null;
builder = factory.newDocumentBuilder();
org.w3c.dom.Document doc = builder.parse(is);
System.out.println("Got Document ..............");
is.close();
org.apache.axis2.saaj.util.SAAJUtil su = new org.apache.axis2.saaj.util.SAAJUtil();
org.apache.axiom.soap.SOAPEnvelope _returnEnv1 = su.getSOAPEnvelopeFromDOOMDocument(doc);
Am getting ClassCastException at the last line in the code (assigning to SOAPEnvelope).
Can someone please help me with this.
Axis2clients are used to send requests and receive response. Why are you trying to load response from a file? You should receive the response from the backend service. Check this guide to get to know about the clientapi. You can find detail guide in axis2 documentation also.