0

So I have been following this documentation provided by Google: https://developers.google.com/actions/identity/user-info

Recently, the request.userId was deprecated so Google. So I turned to this documentation which specifies use the conv.user.storage.

I have tried using the storage property in my app but it seems it doesn't store any user data as the next time I access it, the storage generates a new user id key.

const data = "Something you want to save";
let userId;
// if a value for userID exists in user storage, it's a returning user so we can
// just read the value and use it. If a value for userId does not exist in user storage,
// it's a new user, so we need to generate a new ID and save it in user storage.
if ('userId' in conv.user.storage) {
  userId = conv.user.storage.userId;
} else {
  // generateUUID is your function to generate ids.
  userId = generateUUID();
  conv.user.storage.userId = userId
}

Above is the snippet of the code I tried. I've obviously replaced the generateUUID() function with my own and it's generating a random user id every time. The problem is I could never find 'userId' in conv.user.storage.

I also went in my Google Home app, checked out the "[View user storage]" but it had nothing.

Mithil Bhoras
  • 337
  • 5
  • 14

1 Answers1

2

The userstorage depends on a user setting. Try setting the Web & App permission to on and include the chrome history checkbox.

This setting can be enabled in the activity centre

Jordi
  • 3,041
  • 5
  • 17
  • 36
  • Thank you! This did the trick. But now how do I enable it in Google actions itself when the user does account linking for the first time? Thanks. – Mithil Bhoras Jul 30 '19 at 09:29
  • It should be enabled even when they haven't linked their account yet. Once a user enables that setting, the data will persist between conversations – Jordi Jul 30 '19 at 13:35
  • I mean to say, ask the user in conversation itself whether to enable this feature. We have some testers working on this and even after account linking this feature is disabled for them by default. – Mithil Bhoras Aug 05 '19 at 09:20
  • As far as I know, you cannot enabled this feature for a user. They will have to do it themselves. As far as for the testers, the only guess I can make is that the Web & App settings + chrome history is disabled in their Google Account. The userstorage isn't related to accountlinking. – Jordi Aug 05 '19 at 09:32
  • So do I have to tell the user to enable the feature? Because userstorage is an integral part of the app where we store the userID. Can you suggest the best alternative solution for this or is there no other solution than manually enabling the setting? Thanks for all the help, Jordi! – Mithil Bhoras Aug 07 '19 at 08:08
  • 1
    Out of own experience you have to tell the user to enable it,So far I've not found a solution that allows you to set this for the user in code myself. – Jordi Aug 07 '19 at 08:36