【问题标题】:Google Assitant App not storing user information谷歌助理应用不存储用户信息
【发布时间】:2019-12-06 16:48:44
【问题描述】:

所以我一直在关注 Google 提供的这份文档: https://developers.google.com/actions/identity/user-info

最近,request.userId 已被 Google 弃用。所以我转向这个文档,它指定使用 conv.user.storage。

我曾尝试在我的应用中使用 storage 属性,但它似乎没有存储任何用户数据,因为下次我访问它时,存储会生成一个新的用户 ID 密钥。

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
}

上面是我试过的代码的 sn-p。我显然已经用我自己的函数替换了 generateUUID() 函数,并且它每次都会生成一个随机用户 ID。问题是我永远无法在 conv.user.storage 中找到“userId”。

我还进入了我的 Google Home 应用,查看了“[查看用户存储]”,但它什么也没有。

【问题讨论】:

    标签: actions-on-google google-home google-account google-assist-api account-linking


    【解决方案1】:

    用户存储取决于用户设置。尝试将 Web & App 权限设置为开启并包含 chrome 历史记录复选框。

    这个设置可以在activity centre启用

    【讨论】:

    • 谢谢!这成功了。但是现在当用户第一次进行帐户链接时,如何在 Google 操作中启用它?谢谢。
    • 即使他们还没有关联他们的帐户,也应该启用它。一旦用户启用该设置,数据将在对话之间持续存在
    • 我的意思是,在对话中询问用户是否启用此功能。我们有一些测试人员正在为此工作,即使在默认情况下为他们禁用帐户关联后,此功能也是如此。
    • 据我所知,您无法为用户启用此功能。他们将不得不自己做。至于测试人员,我唯一能做出的猜测是他们的 Google 帐户中禁用了 Web & App 设置 + chrome 历史记录。用户存储与帐号关联无关。
    • 出于自己的经验,您必须告诉用户启用它,到目前为止,我还没有找到允许您自己在代码中为用户设置的解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-30
    • 2012-01-09
    • 1970-01-01
    • 1970-01-01
    • 2012-05-26
    相关资源
    最近更新 更多