var context = agent.context.get('user'); // This works in 90% of users
if (context == null || context == undefined) {
context = agent.context.get('-'); // So, this works in some devices
}
How can I fix it?
My package.json:
{
"name": "dialogflowFirebaseFulfillment",
"description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "8"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "^2.7.1",
"firebase-admin": "^8.1.0",
"firebase-functions": "^3.0.1",
"dialogflow": "^0.10.1",
"dialogflow-fulfillment": "^0.6.1"
}
}
This is blocking me from submitting my app to production.
I have the following code to set an 'user' context in my fulfillment:
agent.context.set({ 'name': 'user', 'lifespan': 5, 'parameters': { 'username': username } });
In some devices (google assistant), when I try to get context using:
agent.context.get('user')
I receive an undefined (my context is not set)
So, I log:
console.log(JSON.stringfy(agent.context));
And I receive the following response:
{ "contexts":{ "-":{ "name":"-", "lifespan":4, "parameters":{ "username":"jfabro" } } } }
The context name is filled wrong with '-'.
This causes me to use an if like this:
How can I fix it?
My package.json: