Daily Updates

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

Prerequisites

At least one of the Actions in your Actions project must be configured as a triggering intent which will be invoked when the user taps a notification received from the Assistant.

Automatic discovery flow

This is the simplest flow to add daily updates to your Action; you only need to configure which triggering intents should trigger a request to subscribe to receive updates. Google takes care of showing the opt-in to the user.

Console setup

Open the Actions console in a web browser, then:

  1. Navigate to Build > Actions.
  2. Click the Action matching the additional triggering intent for which you'd like to enable daily updates.
  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 reference the Actions on Google Updates API sample to show you how to set up advanced features of daily updates for your application. When the user invokes this Action, 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 Action 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 Action.

Start opt-in flow

Configure the intents for which you want updates as explained in the console setup.

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, for example, Send daily.
  3. In the Actions and parameters section on the Intents, add an Action with a name 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 Action, the Assistant triggers the actions.intent.CONFIGURE_UPDATES intent for your Action.

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, passing an UPDATE_INTENT argument that contains the name of the intent selected by the user.

Your Action sends the Assistant an actions.intent.REGISTER_UPDATE intent, 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 Action is built using Dialogflow, 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 example shows 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, for example, tipCategory.
  3. Add some entries and synonyms that are relevant for your parameter. For example, for the tip category in the Actions on Google tips sample we have tools, development, etc.
  4. Click Save, then open the intent you want triggered from the notification, for example, for the Actions on Google tips 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. For example, for the Actions on Google Update API sample, the name of the parameter is category and the entity is tip-category.
  6. Navigate to the intent that you defined to handle the CONFIGURE_UPDATES intent as described in Configure the subscription. For the Actions on Google 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 you 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 with the client library for Actions on Google using 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 Action, you can deploy your test version of the Actions on Google tips sample by following the instructions to set up and run the sample.