How to get correct user or session ID for Google Assistant push notificatons

google-assistant

#1

Hello. I have a question about setting up push notifications for Google Assistant. I followed the steps in the tutorial and everything worked until using the method this.$googleAction.$notification.sendNotification.

This method tries to reach the Google API endpoint POST https://actions.googleapis.com/v2/conversations:send, correct? I tried using that endpoint directly too and it complained that there was an invalid argument. It seems that the result of the method this.$user.getId() (it looks like a UUID) as seen in the example code is not accepted. However, using a session ID manually retrieved from Dialogflow logs (these ID’s start with "ABwppH") works consistently.

There is a comment that says // Save user and the intent to db but how do we get an ID that will be accepted by the Google API?

Is there a method in Jovo to get this ID? Would have liked to stick with this.$user.getId() but its result does not seem to be accepted by Google API (v2) as a valid ID.

Thank you.


#2

Hi, wanted to follow up on the question above and see if anyone may know of any potential solutions. Thanks!


#3

Using this.$user.getId() worked for me. Did you test it with an account that has voice-match enabled?

Apparently you should receive an user ID in the request that is sent when the user has gave you the permission to send notifications, but I didn’t receive it. Maybe it’s only sent if the user is unverified. Try to use that one maybe.


#4

Yes,we did use the this.$user.getId() method and even got an ID result from it, but the returned ID was in UUIDv4 format that the API would mark as an “invalid argument” when we attempted to send a notification object (an example value is aa25d79a-fc76-4d51-99b6-ba4a08c66109).

Further indication that the user ID from this.$user.getUserId() was invalid was that when we manually entered sessionId values retrieved from raw interaction logs in Dialogflow (as opposed to the ID values in UUIDv4 format), we consistently got successful results (a notification would be sent to the user).

A sample user ID value accepted by the Google API is ABwppHHjEyVIwnW4uI1C3v3-0x8xAKqZX1p5Jyor-78Kvkq0vvrEvLoPMGycKg7yO4TBxxrHmStDgtdlISwqVcwGiQ7T (these consistently started with ABwppH ). Could this possibly be related to Google updating the way they set up ID’s for users?

In case testing directly on the Google API endpoint is desired, one can send a POST request to https://actions.googleapis.com/v2/conversations:send. The request body contains the notification object as described in the tutorial documentation page for Google Actions notifications, and a Bearer access token from a Google service account (also just as described in the tutorial documentation) is needed in the header.