Closed AutomataVM closed 4 years ago
before hook function must return the payload:
watsonMiddleware.before = function(message, conversationPayload, callback) {
//Passing values to conversation.
conversationPayload.context.user_name= 'user_name';
return conversationPayload;
}
thank you! this is what I did
watsonMiddleware.before = async (message, payload) => {
if (typeof(payload.context) === 'undefined') {
var context = {
context: {
user_name: '',
age: 0,
residence: '',
civil_state: '',
prev_studies: '',
}}
Object.assign(payload, context);
}
return payload;
};
I wanted to add the user's name before watson middleware started it's operation, like this:
in my end, the next message text's output should be
hello, $user_name !
It's nice to meet youThough I get a watsonErrorwhen processing the answer