Daily Updates

Daily updates are sent to users at a scheduled time every day. If your app makes sense as part of a daily routine, or if users request a similar experience from your app on a regular basis, you can use daily updates. These remind users to trigger your app by sending them a push notification at a scheduled time.

Prerequisites

You need a triggering intent in your Actions project, which is triggered when the user taps a notification received from the Assistant.

Automatic discovery flow

This is the simplest flow to add Daily Updates to your app: all you need to do is configure which triggering intents should trigger a request to subscribe to receive updates, and Google takes care of showing the opt-in to the user.

Console setup

Open the Actions on Google console in a web browser, then:

  1. Navigate to Build > Actions.
  2. Click the Action matching the additional triggering intent you'd like to enable updates for.
  3. Scroll down to the User engagement section and turn on Would you like to offer daily updates to users.
  4. Enter a Content title.
  5. Click Save.

Advanced features (optional)

In this guide we use the AoG Tips sample as a reference to show you how to set up advanced features of daily updates for your application. When the user invokes this app, it asks whether they want to hear a tip about developing an Action. The user can choose either a specific or randomly selected category for the tip, or they can choose to hear the most recent tip.

Opt-in users

If you want your app to control when to show the opt-in chip instead of letting Google handle the flow, you can implement the opt-in flow directly in your app.

Start opt-in flow

Configure the intents you want updates for as explained in the Console setup section of this doc.

When you want to trigger the opt-in flow, send a suggestion chip that invites the user to subscribe. In the following example, we use "Send daily" as the title of the chip:

conv.ask(new Suggestions('Send daily'));
Dialogflow
  1. Add another intent called for example setup_update.
  2. Set the user expression to the exact value of your daily update prompt, e.g. Send daily.
  3. Set the action for the intent to something likeconfigure_updates
Actions SDK

You should configure your NLU solution to trigger the function that handles the actions_intent_CONFIGURE_UPDATES intent if the user expression matches the value of the daily update prompt. A very basic example based on string matching:

const userInput = conv.input.raw;
if (userInput === 'Send daily') {
  conv.ask(new RegisterUpdate({
    intent: 'intent_name',
  }));
}

When a user opts-in to receive daily updates from your application, the assistant triggers the actions.intent.CONFIGURE_UPDATES intent for your app.

Dialogflow

Configure an intent that you could call for example configure_updates , setting actions_intent_CONFIGURE_UPDATES as the event for the intent.

Actions SDK

Declare the intent in your action package.

{
    "actions": [

      // other actions here

      {
        "description": "Configure Update Intent",
        "name": "Configure update",
        "fulfillment": {
          "conversationName": "configureUpdate"
        },
        "intent": {
          "name": "actions.intent.CONFIGURE_UPDATES"
        }
      }
    ],
    "conversations": {

      // other conversations here

      "configureUpdate": {
        "name": "configureUpdate",
        "url": "YOUR_ENDPOINT_URL",
        "fulfillmentApiVersion": 2
      }
    }
  }

Configure the subscription

When the user taps the opt-in suggestion chip, the Assistant triggers the actions_intent_CONFIGURE_UPDATES intent of your app, passing an UPDATE_INTENT argument that contains the name of the intent selected by the user.

Your app sends back to the Assistant an actions.intent.REGISTER_UPDATE intent, setting which intent the notification triggers and the frequency of the notifications.

Node.js
app.intent('setup_update', (conv) => {
  const intent = conv.arguments.get('UPDATE_INTENT');
  conv.ask(new RegisterUpdate({
    intent: intent,
  }));
});
json
{
   "conversationToken":"",
   "expectUserResponse":true,
   "expectedInputs":[
      {
         "inputPrompt":{
            "initialPrompts":[
               {
                  "textToSpeech":"PLACEHOLDER_FOR_REGISTER_UPDATE"
               }
            ],
            "noInputPrompts":[

            ]
         },
         "possibleIntents":[
            {
               "intent":"actions.intent.REGISTER_UPDATE",
               "inputValueData":{
                  "@type":"type.googleapis.com/google.actions.v2.RegisterUpdateValueSpec",
                  "intent":"tell.tip",
                  "triggerContext":{
                     "timeContext":{
                        "frequency":"DAILY"
                     }
                  },
               }
            }
         ]
      }
   ]
}

Finalize the subscription

If your app is a Dialogflow app, you need to:

  1. Add one more intent called, for example, finish_update_setup, and set actions_intent_REGISTER_UPDATE as its Event.
  2. Set the intent's Action to finish.update.setup.

To finalize the subscription from your Node.js webhook:

app.intent('finish_update_setup', (conv, params, registered) => {
  if (registered && registered.status === 'OK') {
    conv.close(`Ok, I'll start giving you daily updates.`);
   } else {
    conv.close(`Ok, I won't give you daily updates.`);
   }
});

Personalize daily updates

You can personalize your daily updates to create experiences tailored for each user. To do this, specify an argument value when you opt the user in. This will be passed to the intent triggered by a notification.

Define a parameter

The following is a basic example of how to set a parameter. In your app you can use different strategies, for example let the user choose from a list or a carousel.

Dialogflow
  1. Open the app in the Dialogflow console and navigate to the Entities page.
  2. Click Create Entity and give a name to the entity, e.g. tipCategory.
  3. Add some entries and synonyms that are relevant for your parameter. For example, for the tip category in AoG Tips we have tools, development, etc.
  4. Click Save, then open the intent you want triggered from the notification, e.g for the Aog Tip sample the tell_tip intent.
  5. In the Actions and parameters section, set actions.intent.CONFIGURE_UPDATES as the event. In the same section, add a parameter with the name of your choosing and set the type to the entity previously created. E.g. for the AoG Tip sample, the name of the parameter is category and the entity tip-category.
  6. Navigate to the intent that you defined to handle the CONFIGURE_UPDATES intent as described in Configure the subscription. For the AoG Tips sample, this is the setup_update intent.
  7. In the Actions and parameters section, add a required parameter with the name of your choosing and set the type to the entity previously created.

The following snippet shows how to read the value of the parameter and use it in the registration request using the AoG Client Library for Node.js.

app.intent('setup_update', (conv, {category}) => {
  conv.ask(new RegisterUpdate({
    intent: 'intent_name',
    arguments: [
      {
        name: 'category',
        textValue: category,
      },
    ],
    frequency: 'DAILY',
  }));
});
Action SDK

The function that handles the actions_intent_CONFIGURE_UPDATES should ask the value for the parameter, which is then used in the following turn to register. The following snippets provides an example of how it could be done using the AoG Client Library for Node.js.

app.intent('actions.intent.CONFIGURE_UPDATES', (conv, {category}) => {
  conv.ask(new RegisterUpdate({
    intent: 'intent_name',
    arguments: [
      {
        name: 'category',
        textValue: category,
      },
    ],
    frequency: 'DAILY',
  }));
});

app.intent('actions.intent.TEXT', (conv, input) => {
  if (input === DAILY_NOTIFICATION_SUGGESTION) {
    conv.ask('For which category do you want to receive daily updates?');
  }
});

Test daily updates

If you want to test daily updates but don't have your own app, you can deploy your test version of the AoG Tips sample by following the instructions to set up and run the sample.