0

I am making a google action.I have one scenario where calculation requires some time in cloud fulfillment but i don't want to keep user waiting for answer. I want to respond to user whenever my answer is ready even when conversation with user is ended i want to send my answer in notification or something like that.

I just found this on google actions documents. https://developers.google.com/actions/assistant/updates

Is this possible in google actions and how?

Shubham Zemse
  • 49
  • 1
  • 8

2 Answers2

2

What you mean here is notifications. You can use it but please pay attention to the warning at the top of the link you provided: "Updates and notifications are currently in Developer Preview. You can build apps using the features described in this article, but you can't currently publish them".

As for the steps to crated a daily notification:

  1. Navigate to your actions.intent.CONFIGURE_UPDATES intent.
  2. Under Responses, go to the Google Assistant tab, click Add Message Content, and select Custom Payload.

    1. In the "Custom Payload" box, add the following code to call the AskToRegisterDailyUpdate helper. Swap INTENT_NAME to the intent that you want to be invoked when the user interacts with your notification.

    {

    "google": { 
       "system_intent": {
        "intent": "actions.intent.REGISTER_UPDATE",
        "data": {"@type": "type.googleapis.com/google.actions.v2.RegisterUpdateValueSpec",
        "intent": "INTENT_NAME",
        "triggerContext": { 
           "timeContext": { "frequency": "DAILY" }
        }
      }
    }
    

    } }

    1. If using a webhook, you can call this API directly via the client library:

      appMap.set('setup_update', function(app) { 
        app.askToRegisterDailyUpdate('INTENT_NAME'); 
      })
      

      })

    2. Add one more intent called "finish_update_setup" and enter actions_intent_REGISTER_UPDATE as its Event.

    3. Set the intent's Action to "finish_update_setup" as well.

    4. In your webhook, open index.js and add the following. Replace Ok, I'll start giving you daily updates and Ok, I won't give you daily updates. with whatever response you want to give the user:

      appMap.set('finish_update_setup', function(app)) {
        if (app.isUpdateRegistered()) {
          app.tell("Ok, I'll start giving you daily updates.");
        } else {
          app.tell("Ok, I won't give you daily updates.");
        }
      }
      
    5. Deploy the webhook to Firebase Functions and enable webhook fulfillment in Dialogflow.

If you want to see how to create a simple notification (not daily one) - please check this doc on push notifications.

SysCoder
  • 715
  • 7
  • 18
Ido Green
  • 2,795
  • 1
  • 17
  • 26
-2

If you don't have an immediate reply to send but expect one soon-ish what you do is return a "promise". When you are in a position to reply, "fulfilling" the promise causes your reply to be delivered. I don't know what the actual timeout is but in my case I'm pretty sure at least a few second delay is allowed.

As for the updates or notifications, the API is there but the docs say you can't deploy an Action to production using them. There is a slightly cryptic comment to "contact support" if you need them.

One of these days I might try.

William DePalo
  • 615
  • 4
  • 8