Reputation: 270
I am trying to update some Dialog profile variables via the watson-developer-cloud library. The client_id variable seems to be ignored, and is being set to a random number. As a result, the profile variables are not being set. This is the endpoint in my API that is supposed to do the update:
app.put('/update', function(req, res)
{
setHeaders(req,res); //set up headers for CORS
var parms=req.body;
parms.dialog_id=dialogId;
console.log("Processing PUT /update...");
console.log("Setting: ",parms);
dialog.updateProfile(parms,function(err, results)
{
if (err)
{
console.log(err);
res.status(500);
res.send(err);
}
else
{
console.log('Update returning: ',results);
res.send(results);
}
});
});
and this is a sample value for parms (shown here after JSON.stringify(parms):
{"client_id":12345,"dialog_id":"4a6e3699-10ab-4703-86bb-0b74384aaf94","conversation_id":245895,"name_values":[{"name":"CPE_Name","value":"Tracey Moon"},{"name":"CPE_Name","value":"Kellogg"},{"name":"CPE_StateTerritory","value":"California"}]}
Is this a bug in the watson-developer-cloud library?enter code here
Upvotes: 0
Views: 298
Reputation: 547
The problem is apparently a bug in an earlier version of the watson-developer-cloud package. Running
npm install watson-developer-cloud@latest
as described in this post seems to have fixed the problem.
Upvotes: 0
Reputation: 190
Here's a code snippet which does the getConversation to get a client id and then an updateProfile to set a profile var:
var watson = require('watson-developer-cloud');
var dialogid = <dialog_id>;
var clientid = '';
var dialog = watson.dialog({
username: <username>,
password: <password>,
version: 'v1'
});
dialog.conversation({dialog_id: dialogid}, function (err, dialogs) {
if (err)
console.log('error:', err);
else{
console.log('Started conversation with dialog id ' + dialogid + '.');
console.log(JSON.stringify(dialogs, null, 2));
clientid = dialogs.client_id;
}
});
dialog.updateProfile({ client_id: clientid, dialog_id: dialogid, name_values: [{"name":"Topic","value":"Education"}]}, function (err, dialogs) {
if (err)
console.log('error:', err);
else{
console.log('Set profile variable "Topic" to "Education".');
console.log(JSON.stringify(dialogs, null, 2));
}
});
The above code works for me. Hope it helps!
Upvotes: 1
Reputation: 849
Going off the swagger doc here:
https://watson-api-explorer.mybluemix.net/swagger.html?url=/listings/dialog-v1.json#/
I would hit the following endpoint:
https://gateway.watsonplatform.net/dialog/api/v1/dialogs/7eb167d5-f581-40d3-b91a-ad9c142282ad/profile
with the following in the body:
{
"client_id": 155351,
"name_values": [
{
"name": "Name",
"value": "Mitch"
}
]
}
Upvotes: 1