User Data & Permissions
Learn more about how to get access to Google Action user information.
Introduction
User information is mainly used to offer a more personalized experience, but you can't access it right away. First you have to ask for permission.
User ID
In previous versions of Jovo, the userId
for Google Actions was taken from the request's user ID. In 2018, Google deprecated this element of the request JSON and recommended webhook generated user IDs as an alternative way to store user data.
In Jovo, a Google Action userId
is created in the following process:
- If there is a
userId
defined in the userStorage, take this - If not, use the
userId
from the request (if there is one) and then save it inuserStorage
- If there is no
userId
in the request, generate one usinguuidv4
, and then save it touserStorage
Note: userStorage
only works for Google Assistant users who have voice match enabled. Learn more in the official Google Docs.
ON_PERMISSION
After the user has answered your request, they will be redirected to the ON_PERMISSION
intent, if available, where you can access and store the data.
Name
You can get access to the user's given name
, family name
and display name
.
Location
Get access to the user's location. Depending on the device the request comes from and the permission you have, you can get access to different data.
If it's a phone, you can only access the latitude
and longitude
with the DEVICE_PRECISE_LOCATION
permission.
On a voice-enabled speaker you can access all of the data, depending on the permission you have.
Place and Location
You can also prompt the user for their current location using the askForPlace()
helper:
The user's response will be mapped to the ON_PLACE
intent, where you can access the user's input using the getPlace()
method:
Here's an example for the place object you will receive:
Date and Time
You can request the user's date and time using the following helper method:
The user's response will be mapped to the ON_DATETIME
intent, where you can access their response object using this.$googleAction.getDateTime()
:
Here's an example how the DATETIME
object you receive would look like:
Account Linking
To implement Account Linking in your voice application, you need two core methods.
The first allows you to prompt the user to link their account, using the askForSignIn()
method. Optionally, you can parse a string to specify the purpose for which your app needs the user to sign in:
After the user has responded to your account linking request, you will receive a request to notify you about the result, which will be mapped to the Jovo built-in ON_SIGN_IN
intent. Using the getSignInStatus()
method you can get the result:
If the user signed in successfully, an access token will be added to every request your skill receives. You can access it using the getAccessToken()
method:
For a complete walk-through, check out our tutorial: Google Actions Account Linking