App Exits

Whenever users want to exit your app mid-conversation, they can say things like:

  • "exit"
  • "cancel"
  • "stop"
  • "nevermind"
  • "goodbye"

By default, the Assistant exits your app and plays an earcon. To override this behavior, you can opt-in to receiving one last request that you can use to cleanup your fulfillment logic and respond to the user one last time.

Dialogflow

To receive app exit events:

  1. In the left navigation, click the + icon by the Intents menu item.
  2. Give the intent a name and click on the Events section.
  3. Enter actions_intent_CANCEL in the Add event field.
  4. In the Actions section, enter an action name. For this example, we'll use say.bye.
  5. Specify a response in Dialogflow's Response section or return one in your fulfillment code.
  6. Click Save.
  7. In the left navigation, click Integrations
  8. Choose Google Assistant and click UPDATE DRAFT, then TEST to make sure the changes are reflected in your app.

When a user requests an app exit, the intent you created is triggered and your response is returned to the user. For example, here's some fulfillment code that uses the client library to handle a cancel intent and return a response:

const CANCEL_EVENT = 'say.bye'; //name of the action

...

function sayBye (app) {
    app.tell(`Okay, let's try this again later.`);
}

let actionMap = new Map();

...

actionMap.set(CANCEL_EVENT, sayBye);
app.handleRequest(actionMap);

Actions SDK

To receive app exit intents:

  1. In a conversations object inside your action package, declare that you want to receive the actions.intent.CANCEL intent whenever a user wants to exit your app mid-conversation:

    "conversations": {
      "myConversation": {
        "name": "myConversation",
        "url": "https://my.fullfillment.com/conversation",
        "in_dialog_intents": [
          {
            "name": "actions.intent.CANCEL"
          }
        ]
      }
    }
    
  2. When you receive a request with the actions.intent.CANCEL intent, clean up any fulfillment logic that you'd like and return an appropriate exit phrase to the user. For example, here's some fulfillment code that uses the client library to handle a cancel intent:

    function sayBye (app) {
        app.tell(`Okay, let's try this again later.`);
    }
    
    let actionMap = new Map();
    
    ...
    
    actionMap.set(app.StandardIntents.CANCEL, sayBye);
    app.handleRequest(actionMap);