I am trying to call IBM Watson using Node, in order to get the list of dialog nodes from my Workplace. I am using the listDialogNodes from the API documentation.
This is the code I am using:
var watson = require('watson-developer-cloud');
var conversation = new watson.ConversationV1({
username: USERNAME,
password: PASSWORD,
version_date: '2017-05-26'
});
var params = {
workspace_id: WORKSPACE_ID,
};
conversation.listDialogNodes(params, function(err, response) {
if (err) {
console.error(err);
} else {
console.log(JSON.stringify(response, null, 2));
}
});
I keep getting the error 'conversation.listDialogNodes is not a function' even though this code is an example taken from the API page, save of course the USERNAME, PASSWORD and WORKSPACE_ID.
I have another method to send a message to Watson and that one is working fine, so it shouldn't be credentials or something like that.
I just took the latest node-sdk (3.0.4) for watson-developer-cloud and checked the node-modules for it.
Surprisingly, IBM has made a joke out of it. In the node-modules the command to get the list of dialog nodes is ConversationV1.prototype.getDialogNodes
(getDialogNodes) instead of ConversationV1.prototype.listDialogNodes
(listDialogNodes) as mentioned in the documentation.
Once you change your code accordingly, it works smoothly.
conversation.getDialogNodes(params, function(err, response) {
if (err) {
console.error(err);
} else {
console.log(JSON.stringify(response, null, 2));
}