Search code examples
actions-on-googlegoogle-homegoogle-accountgoogle-assist-apiaccount-linking

Google Assitant App not storing user information


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.


Solution

  • 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