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 Invocation and Discovery 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:
- Click Intents in the navigation menu.
- Select the intent that you want to set as the welcome event.
- In the Events section of the intent, enter
Figure 1. A screenshot of the Events section of a Dialogflow intent.
From the Google Assistant integration modal window:
- Click Integrations in the navigation menu and click Google Assistant. (The Google Assistant modal window appears).
- Click X to remove the current item in the Explicit invocation field.
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).
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:
- Scroll to the bottom of the intent editor of an intent.
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:
- Create an intent for a specific Action that you want to build.
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 for an intent.
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.)
Click Integrations in the navigation menu and click Google Assistant. (The Google Assistant modal window appears.)
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
- Be much more specific; for example,
find recipes for @sys.any.
- Be much more specific; for example,
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:
- In the navigation menu, click Intents.
- Click CREATE INTENT and name your intent.
- In the Contexts section, Specify
google_assistant_welcomeas the input context and press enter key. (After entering the input context,
google_assistant_welcomeappears as an output context).
Click x to remove that output context.
In the Training phrases, add
banana(or any other noun) as a user expression.
Double-click on banana and select
@sys.any. (We use the
@sys.anyentity to tell Dialogflow to generalize the expression to any grammar, not just banana.)
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.