Routine Suggestions

To consistently re-engage with users, you need to become a part of their daily habits. Google Assistant users can already use Routines to execute multiple Actions with a single command, perfect for those times when users wake up in the morning, head out of the house, get ready for bed or many of the other tasks we perform throughout the day. Now, with Routine Suggestions, after someone engages with your Action, you can prompt them to add your Action to their Routines with just a couple of taps.

Prerequisites

You need a triggering intent in your Actions, which is triggered when the user executes their Routine.

Automatic discovery flow

This is the simplest flow to add Routine Suggestions to your app: all you need to do is configure which triggering intents should trigger a request to add to the user's routines, 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 do the following:

  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 let users add this Action to Google Assistant Routines?.
  4. Enter a Content title.
  5. Click Save.

Control user opt-in (optional)

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 to suggest for routines 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 "Add to routine" as the title of the chip:

conv.ask(new Suggestions('Add to routine'));
Dialogflow
  1. Add another intent called for example setup_routine.
  2. Set the user expression to the exact value of your "add to routine" prompt, e.g. Add to routine.
  3. Set the action for the intent to something likeconfigure_routines
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 your "add to routine" prompt. A very basic example based on string matching:

const userInput = conv.input.raw;
if (userInput === 'Add to routine') {
  conv.ask(new RegisterUpdate({
    intent: 'intent_name',
    frequency: 'ROUTINES'
  }));
}

When a user opts-in add your action to their routines, 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 ROUTINES as the frequency.

Node.js
app.intent('setup_update', (conv) => {
  const intent = conv.arguments.get('UPDATE_INTENT');
  conv.ask(new RegisterUpdate({
    intent: intent,
    frequency: 'ROUTINES'
  }));
});
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":"ROUTINES"
                     }
                  },
               }
            }
         ]
      }
   ]
}

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'm now part of your routine!");
   } else {
    conv.close("Ok, I'm not part of your routine.");
   }
});