rajasaur
rajasaur

Reputation: 5450

Return response to Google Assistant via API

I have a Actions on Google project that uses api.ai for its actions. This is working well and I can see request/responses appear on the google assistant interface (On mobiles and simulator)

One of my usecases for api.ai needs to broken into 2 parts, in that we have to inform the user that the processing has started and then inform them again once its completed (without them reprompting for the output).

Im trying for a way to inform the user who is using the Google assistant when the processing is completed, but have failed so far. Something like this

User: I would like to see if my loan request is approved

Google Assistant: Hold on, let me check and let u know .

.... (Makes a webservice call to the backend asynchronously)

.... After few seconds ...

.... Postback to google assistant from the webservice

Google Assistant: Thanks for holding, your request is approved.

Im not sure how to do the "postback to google assistant" call. I have tried to get the SessionId from the Api.AI call and then use that to make a event request , but that doesnt seem to send the response to the assistant. Google Assistant seems to be using the formats defined in https://developers.google.com/actions/reference/rest/Shared.Types/AppRequest, but Im unsure how to get the ConversationToken and use that for sending the response back to the user.

Upvotes: 1

Views: 945

Answers (1)

Prisoner
Prisoner

Reputation: 50701

Short answer: you can't do that.

Slightly longer answer: At least right now, there is no good way to send a notification. Your Action can only respond to a specific statement from the user. You can say something like "ask again in a minute and I should have a result for you", but that isn't a great experience. At Google I/O 2017, they announced that notifications would be coming to the Google Home at some point... but gave neither a time frame nor any information about an API.

Long, but probably still unsatisfying answer: You can look into Transactions which let them initiate purchase or request of some sort and then "check out". Once they have checked out, you would confirm that a transaction is being processed with an OrderUpdates and then can send updates with the status of the "order". These status updates can turn into notifications or user's can query the state of the order at any time. Transactions don't require payment, so this may work depending on your needs.

However, there are a few things to note. This is still in developer preview, so things may change in the future. It also doesn't work on all surfaces where the Assistant runs, so while it does work on Assistant on phones, it does not work on the Google Home right now.

Upvotes: 3

Related Questions