Blasco
Blasco

Reputation: 1745

How can I access user data stored in Firebase using Google Assistant?

I have some user data stored in Firebase in users/userID/data

I'm using Dialogflow to recognize for example the following intent:

retrieve my email

which triggers a webhook and passes as parameter email, which is the data the user wants to retrieve. How to I pass the firebase userID? I guess I need to implement some kind of logging for the Google Assistant, but I cannot find how can I link the Firebase user account to google actions and how would I get this firebase userID

Is there a standard or recommend way to achieve this?

Upvotes: 0

Views: 388

Answers (1)

Prisoner
Prisoner

Reputation: 50701

There is no pre-built solution for this right now.

You will need to implement Account Linking with the Google Assistant.It was done this way to give you, and your users, maximum flexibility. You'll be able to authenticate them using a variety of methods, not just Google Auth, and users are able to use a Google identity for you that may be different than the one they use for the Assistant. Account Linking will associate them without revealing to you which account they use on the Assistant.

This means creating an OAuth server that lets users log in using their Firebase account and issuing tokens to the Assistant. Google does provide some information about the procedure you should follow when creating your OAuth server, and you should be able to create this using Firebase Hosting and Firebase Cloud Functions.

Then, each time the Assistant calls your action, it will send the tokens back to you. You would use this token to determine the Firebase userid and then can look them up in the database.

Upvotes: 1

Related Questions