I am creating a chat bot with Twilio Autopilot, and I am trying to retrieve a variable that I save in a function from another function with Action Remember.
This is my first function:
exports.handler = function(context, event, callback) {
console.log(Object.keys(event));
let memory = event.Memory;
let respObj = {};
console.log("Memory "+memory);
let msg = "Hi, im save the name";
respObj = {
"actions": [
{
"say": msg
},{
"remember": {
"myname": "pau"
}
}
]
};
console.log("Memory "+memory);
callback(null, respObj);
};
This is my second function:
exports.handler = function(context, event, callback) {
let responseObject = {};
let memory = JSON.parse(event.Memory);
let ret = memory.myname;
console.log(ret);
console.log("Memory "+memory);
responseObject={
"actions":[
{
"say":"your name is" + ret
}
]
};
callback(null, responseObject);
};
I get an undefined of the variable, when I call this second function.
I would appreciate if someone could help me. Thank you!!! Regards.