1

I'm currently trying to store some data via the assistant in the local storage to the device or to the Google Account.

Example:

I call in the Google Assistant my assistant app. This now asks for saving a note, which should be stored somewhere. I'm using a webhook, which sends the request from Google to my web server and process there the data.

My thoughts

Of course, I could save the data in a MySQL database, but without any credentials, I can't store it for this specific person. My first idea was to save it to a cookie, but unfortunately, API.AI (which I use for the Google Assistant app) will create always a new session, so I can't save it there.

I also saw that I can add account-linking to the app. But I don't know if this service is built for that? Is there another way to solve this problem?

Thank you so much for every response.

dmonopoly
  • 3,251
  • 5
  • 34
  • 49
Julian Schmuckli
  • 3,681
  • 11
  • 37
  • 64

1 Answers1

2

You do not have access to the Google Account that is used on the Google Assistant. You also don't have access to the local storage of the device the Assistant is running on - keep in mind that they can access the Assistant from multiple devices at once.

As part of the information your webhook is sent through the Assistant, you can get a unique, but anonymous, UserID which you can treat similarly to a web cookie. Unless the user takes a deliberate action to revoke this ID, it will be consistent for this person across all devices their account is tied to through the Assistant.

You can use this ID to store information about or for the user in a database (for example, Firebase Database) in the cloud or on your servers, since the next time they use your service they will present with the same ID, but you can't directly send it back to be stored on the user's Android or iOS device. Since users can access the Assistant (and, therefore, your Action) across multiple devices, this may be a good thing.

There is, additionally, a Session ID available. As you surmise, this is new for each session and not tied to a user. There are some cases where it will produce a new UserID for each session, but these are cases where the user is using a generic/default account on their Google Home, so you couldn't trust that the physical person returning was the same as the one that contacted you before.

Account linking may help you in some cases, but requires a great deal of extra work. If you link their Assistant account "your" account, and your account has permission to send them something like a Firebase Cloud Message, you might be able to write an app that runs on the device and handles the FCM by storing the data in local storage.

Prisoner
  • 49,922
  • 7
  • 53
  • 105