DialogFlow conv.user.id已淘汰-有何影响? [英] DialogFlow conv.user.id Deprecated - any implications?

查看:91
本文介绍了DialogFlow conv.user.id已淘汰-有何影响?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Similar to DialogFlow V2 user id? I am using the user ID from conv.user.id (dialogflow v2) to (anonymously) determine the user in my Dialogflow app. However, I get the log message:

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

这是否意味着我(不久)将不再有权访问用户ID?我知道我可以将数据存储在conv.user.storage中,但是我需要ID-而不是存储。

Does this mean I will (soon) no longer have access to the user id? I understand I can store data in conv.user.storage, yet I need the id - not the storage.

有人想过如何对它进行故障保护吗?

Anyone thoughts on how to fail-safe this?

//代码段:

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


推荐答案

匿名用户身份已弃用,并将于2019年6月1日(一年后)正式删除。因此,您的代码段将开始失败。

The anonymous user identity has been deprecated and will be officially removed starting 1 June 2019 (a year from now). So your code snippet will start failing then.

此修复程序完全取决于您使用id的方式和原因,但是对于最基本的需求,您可以执行一些操作像这样:

The fix depends on exactly how and why you're using the id, but for the most basic needs, you can do something like this:


  1. 检查是否在用户存储区中存储了ID。如果有,请使用此ID。

  1. Check to see if you've stored an id in the userStore. If you have - use this id.

如果没有,请生成一个ID(生成UUID是执行此操作的好方法),请使用作为您的ID,并将其存储在userStore中以备将来参考。

If you haven't, generate an id (generating a UUID is a good method to do this), use this as your id, and store it in the userStore for future reference.

执行此操作的代码可能类似于以下内容:

Code to do this might look something like this:

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登录助手即可

编辑:
条件中的userId。

userId in condition should be quoted.

这篇关于DialogFlow conv.user.id已淘汰-有何影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆