On the Actions on Google site I find a function for getting the userID to identify a user across conversations and devices. In the docs section under getUser I read following:
getUser() returns User
Gets the User object. The user object contains information about the user, including a string identifier and personal information (requires requesting permissions, see askForPermissions).
So first i need to request permission. For this i follow the link. But there i find only three permission that can be request.
Theres no permission to granted for the userID. And when i run my code and try getting the userID it return undefined. Getting the userName works fine.
function requestPermissonsIntent(app){
const permission = [app.SupportedPermissions.NAME];
app.askForPermission('Für eine korrekte Ausführung', permission);
}
//later in my code when asking for the userID and userName
if(app.isPermissionGranted()){
const userName = app.getUserName().displayName;
//getting the userName works fine
const userUID = app.getUser().userID;
//userUID is undefinded
...
How can I get the UserID?
It should be a lowercase "d".
app.getUser().userId;
You don't need to ask for any permission to get this userId. The string identifier returned is unique for this user in your Action. It should carry across devices if they use the same account.
Update
This has been deprecated as of May 2018, and is scheduled to be discontinued in May 2019.
If you need a userid, you have a few options:
Create your own userid and save it in the user storage object, which will persist between conversations. (Users can empty this storage at any time, however.)
Use Google Sign In for Assistant, which lets the user grant permission for you to get their Google ID, along with other profile information, every time your webhook is called.