Define Actions (Dialogflow)

To define Actions in Dialogflow, you create intents in your Dialogflow agent and assign them as entry points into your Action. You can create the following types of Actions:

  • Default Action: Every Dialogflow agent must have one and only one Action that's invoked when users ask for your Action by name (for example, "Ok Google. Talk to Facts about Google" or "Ok, Google. Let me talk to Facts about Google").
  • Additional intents to deep link into your conversation: These Actions are triggered when users invoke your Action by its name and specify an invocation phrase (for example, "talk to Facts about Google for history facts").

See Intents and invocation for more information on how these invocation models work.

Define a default Action

Every Dialogflow agent must have one and only one intent that handles the GOOGLE_ASSISTANT_WELCOME event. This intent is triggered when users invoke your Action by its name (for example, "Ok Google, talk to Facts about Google").

You can define the GOOGLE_ASSISTANT_WELCOME event in the following ways:

From the intent editor on the Dialogflow console:

  1. Click Intents in the navigation menu.
  2. Select the intent that you want to set as the welcome event.
  3. In the Events section of the intent, enter GOOGLE_ASSISTANT_WELCOME.
  4. Click Save.

    Figure 1. A screenshot of the Events section of a Dialogflow intent.

From the Google Assistant integration modal window:

  1. Click Integrations in the navigation menu and click Google Assistant.
  2. Click X to remove the current item in the Explicit invocation field.
  3. In the Welcome intent box, select the intent that you want to set as the welcome event.

    Figure 2. A screenshot of the Google Assistant integration modal window on the Dialogflow console.

When you view the intent's Events section, you should see that the intent now has the GOOGLE_ASSISTANT_WELCOME event set (see Figure 1).

Enable fulfillment

By default, a Dialogflow intent returns a static response, which is specified in Response section of the intent. This setting might be enough for simple Actions that only need to respond with the same message when invoked. However, if you want the intent to return a dynamic response, you need to provide fulfillment that can process complex logic and compose a response in real time for the intent.

To enable fulfillment for an intent, do the following:

  1. Scroll to the bottom of the intent editor of an intent.
  2. Click Fulfillment and select Enable webhook call for this intent.

    Figure 3. A screenshot of the Fulfillment section of a Dialogflow intent.

See Build fulfillment for information on how to handle this intent when it's triggered.

Define additional Actions

You can provide additional Actions that act as entry points into your conversation. This setup allows users to specify more details about what they want to do (for example, "Talk to Facts about Google to find me history facts").

To define additional Actions in Dialogflow, follow these steps:

  1. Create an intent for a specific Action that you want to build.
  2. In the intent's Training phrases section, specify the patterns that trigger this Action. For example, if you want the Action to be invoked by the phrase "Talk to Facts about Google to find me history facts", provide the following Training phrases:

    • "Find me history facts"
    • "Look up history facts"
    • "Get me facts about history of the company"
    • "Read me some headquarters facts"
    • "Tell me a few facts about its headquarters"

    We recommend at least 10 training phrases per intent.

  3. To enable fulfillment for the intent, scroll to the bottom of the screen, click Fulfillment, and select Enable webhook call for this intent. (See Build fulfillment for more details on fulfillment.)

  4. Click Save.

  5. Click Integrations in the navigation menu and click Google Assistant. (the Google Assistant modal window appears.)

  6. In the Implicit invocation section, add the intent.

    Figure 4. A screenshot of the Implicit invocation section on the Google Assistant integration modal window.

When defining Actions, the following restrictions and guidelines apply:

  • Don't include the reserved words in invocation phrases.
    • For example, don't start your invocation phrases with "talk to" or "let me talk to".
  • Don't specify training phrases that contain only a @sys.any entity.
    • Be much more specific; for example, find recipes for @sys.any.

Handling an unrecognized Action

When users attempt to invoke an Action that your Actions don't recognize, Dialogflow can trigger an intent to handle these cases.

To enable this behavior, create a new intent with an input context of google_assistant_welcome and specify the appropriate responses to users:

  1. In the navigation menu, click Intents.
  2. Click Create Intent and name your intent.
  3. In the Contexts section, Specify google_assistant_welcome as the input context and press enter key. (After entering the input context, google_assistant_welcome appears as an output context).
  4. Click x to remove that output context.

  5. In the Training phrases, add banana (or any other noun) as a user expression.

  6. Double-click on banana and select @sys.any. (We use the @sys.any entity to tell Dialogflow to generalize the expression to any grammar, not just banana.)

  7. In the Response section, specify a responses using $any. For example, use the following response:

    • I'm sorry, I don't know how to help with $any.

  8. Click Save.