I have an Google Action based on DialogFlow fulfillment, it had one issue related to the issue #149 and to resolve it i updated this project to its latest release.
Seems like context api is updated and i tried to use as suggested in various issues. The context is set the first time i set the object like
const ctx = {
"lifespan": 5,
"name": "mycontext",
"parameters": {
a: 1,
b: 2,
score: 0,
}
};
agent.context.set(ctx);
Since i have a conversational action, where the context is updated until the action is complete, the next time i set the context similar to above is not updating the context.
I tried deleting the context and setting again too like
agent.context.delete("mycontext");
agent.context.set(ctx);
Its not working as the version 0.5.0 anymore.
My current dependencies are
"dependencies": {
"actions-on-google": "^2.4.1",
"firebase-admin": "^5.13.1",
"firebase-functions": "^2.0.2",
"dialogflow": "^0.6.0",
"dialogflow-fulfillment": "^0.6.1"
}
please suggest a solution
Your parameters need to be strings, you can see more about this in our docs. Yes you'll need to use the latest dialogflow-fulfillment dependency version, "0.6.1".
agent.context.set({
'name':'context-name',
'lifespan': 5,
'parameters':{
'parameter-name':'parameter-value'
}
});
Why can't it take integers? Previously it could and it's not that much different from a string.
0
I found the only workaround to reassign a new context object via context.set(ctx). Then it worked.
//update context to show full menu
let context = agent.context.get('user_data');
if (!context) throw "User_data context ius nod defined in PreferrenceAdd"
let context2 = new Object();
context2 = {'name': 'user_data', 'lifespan': 40,
'parameters': context.parameters};
console.log("ctx: = " + JSON.stringify(context2));
context2.parameters.new = false;
context2.parameters.refresh = true;
agent.context.set(context2);
Most helpful comment
Why can't it take integers? Previously it could and it's not that much different from a string.