Closed richielo closed 7 years ago
I even tried 1.3.1 and it gives me watsonMiddleware.updateContext is not a function
updateContext is currently only available in master branch.
updateContextAsync is promisified version created by Promise.promisifyAll(watsonMiddleware);
@germanattanasio please release a new version.
@Naktibalda Thanks a lot for the reply. Any idea when will there be a new version? If it's not happening soon, are there any workarounds at the moment? I just want to update the context and get an alternate response from Watson
I can't answer a question about a new version.
Some workarounds:
a) modify context in after
, send context from controller - https://github.com/watson-developer-cloud/botkit-middleware#using-middlewareafter-and-controller
b) require watson-botkit-middleware/lib/middleware/utils.js
and use its updateContext method.
c) copy the updateContext function from utils to your bot.
I missed the easiest workaround - using master branch with npm:
"botkit-middleware-watson": "git+https://git@github.com/watson-developer-cloud/botkit-middleware.git#master",
Thanks a lot. That fixes things. I am following the example in the README and it's still giving me error. Do you mind helping me out a bit? I am very new to this. Thanks a lot. I am getting this "TypeError: Converting circular structure to JSON"
function search(context, callback){
context.action = "found";
if(context.entertainment == "movies"){
result_1 = movie_dict[context.movie_genre][0];
console.log(result_1);
context.search_result = movie_dict[context.movie_genre];
}
else if(context.entertainment == "music"){
result_1 = music_dict[context.music_genre][0];
console.log(result_1);
context.search_result = music_dict[context.music_genre];
}
callback(null, context);
}
var searchAsync = Promise.promisify(search);
var newMessage = message;
newMessage.text = 'searching';
searchAsync(message.watsonData.context).then(function (context) {
//update context in storage
return watsonMiddleware.updateContext(message.user, context);
}).then(function () {
//send message to watson (it reads updated context from storage)
console.log("before send");
console.log(newMesssage);
return watsonMiddleware.sendToWatson(bot, newMessage);
}).catch(function (error) {
console.log("error")
newMessage.watsonError = error;
}).then(function () {
//send results to user
console.log("after send");
console.log(newMessage);
return processWatsonResponse(bot, newMessage);
});```
The updatecontext function is giving error, I tried calling it like this: watsonMiddleware.updateContext(message.user, watsonMiddleware.storage, {context: context})
You don't need to wrap context in an object.
try watsonMiddleware.updateContext(message.user, watsonMiddleware.storage, context);
I've seen this circular structure
error once and it was happening in debug line at https://github.com/watson-developer-cloud/botkit-middleware/blob/master/lib/middleware/utils.js#L48
@Naktibalda is master
ready for a release? if yes will it be patch
or minor
. I think that after your changes we will have to do a minor
release.
Please write some lines in the CHANGELOG.md
file and I will do a minor release.
Thanks!
Done #72
🎉 1.4.0 is out.
Thanks @Naktibalda!
Thanks a lot for the help @Naktibalda @germanattanasio Close #71
You have to click the button.
Is version 1.4 not available at the moment? If not how do use something similar? Thanks a lot in advance