Google Assistant (Dialogflow)

Integration published by Jovo | 9,735 downloads

Build apps for Google's Assistant platform using Dialogflow

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 in userStorage
  • If there is no userId in the request, generate one using uuidv4, and then save it to userStorage

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.

Official Documentation.

Example

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

Google Assistant Changelog

Current version might be higher than the latest changes displayed below because of updates of dependencies.

2021-07-07 [3.5.4]
  • #948 ✨ Add enableFullScreen and continueTtsDuringTouch (@aswetlow)

2021-02-22 [3.5]

  • #901 Move setResponse from response to after.response middleware (@aswetlow)
2020-11-20 [3.2.3]
2020-11-05 [3.2.1]
  • Fix Transaction API v2/v3 incomptibility

🐛 Bug Fix

  • #716 Corrected logic for retrieving project-ids in staged environments (@m-ripper)

Committers: 3

3.0.11 (2020-04-06)

  • Updated Typescript to 3.8.x
  • Updated Prettier to 2.x

Committers: 2

2.x

Find the 2.x changelog here.

Join Our Newsletter

Be the first to get our free tutorials, courses, and other resources for voice app developers.