DialogFlow conv.user.id 已弃用 - 有什么影响吗?

DialogFlow conv.user.id Deprecated - any implications?

类似于 DialogFlow V2 user id? 我正在使用 conv.user.id (dialogflow v2) 中的用户 ID 来(匿名)确定我的 Dialogflow 应用程序中的用户。但是,我收到日志消息:

 conv.user.id is *DEPRECATED*: Use conv.user.storage to store data instead 

这是否意味着我将(很快)无法再访问该用户 ID?我知道我可以将数据存储在 conv.user.storage 中,但我需要 ID - 而不是存储空间。

有人想过如何避免故障吗?

// 代码片段:

app.intent('Default Welcome Intent', conv => {
  var userID = conv.user.id;
  // do something
});

匿名用户身份 has been deprecated 并将于 2019 年 6 月 1 日(一年后)正式删除。所以你的代码片段将开始失败。

修复具体取决于您使用 ID 的方式和原因,但对于最基本的需求,您可以这样做:

  1. 检查您是否已将 id 存储在 userStore 中。如果你有 - 使用这个 id.

  2. 如果你还没有,生成一个id(生成一个UUID是一个很好的方法),使用它作为你的id,并将它存储在userStore中以备将来参考。

执行此操作的代码可能如下所示:

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
}

或者,您可能希望只计划使用 Google Sign-In for the Assistant,这将为您提供 Google 用户 ID。

编辑: condition中的userId要加引号