I am trying to store a UserId across sessions, following the reference found here: https://developers.google.com/assistant/conversational/save-data
Here is my implementation in code:
'use strict';
const { dialogflow } = require("actions-on-google");
const functions = require("firebase-functions");
const app = dialogflow();
app.intent('Default Welcome Intent', (conv) => {
conv.user.storage.userId = "bananas";
console.log("Logging the conversation object... ");
console.log(JSON.stringify(conv));
conv.close("Goodbye! ");
});
exports.yourAction = functions.https.onRequest(app);
When I invoke the action via my Google home hub, it will set my user storage data correctly:
"user": {
"raw": {
"locale": "en-US",
"lastSeen": "2020-02-12T14:28:49Z",
"userVerificationStatus": "VERIFIED"
},
"storage": {
"userId": "bananas"
},
"locale": "en-US",
"verification": "VERIFIED",
"permissions": [],
"last": {
"seen": "2020-02-12T14:28:49.000Z"
},
"name": {},
"entitlements": [],
"access": {},
"profile": {}
},
However, when i comment out the storage assignment in the code, and re-invoke the action, the contents of the user storage are no longer present:
"user": {
"raw": {
"locale": "en-US",
"lastSeen": "2020-02-12T14:31:30Z",
"userVerificationStatus": "VERIFIED"
},
"storage": {},
"locale": "en-US",
"verification": "VERIFIED",
"permissions": [],
"last": {
"seen": "2020-02-12T14:31:30.000Z"
},
"name": {},
"entitlements": [],
"access": {},
"profile": {}
},
I can see that my verification is "VERIFIED", so it can't be that issue. I notice in this docs that the userStorage will clear if:
So maybe it's one of these - however I'm not sure where I can check!
Fixed. I did not have my chrome history setting enabled! This thread goes into more detail: actions on google userStorage only during session