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
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?
// Code snippet:
app.intent('Default Welcome Intent', conv => {
var userID = conv.user.id;
// do something
});
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.
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:
Check to see if you've stored an id in the userStore. If you have - use this id.
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
}
Alternately, you may wish to just plan to use Google Sign-In for the Assistant which will get you the Google UserID.
EDIT:
userId in condition should be quoted.