Actions are entry points into your app that define the invocation and discovery model for your app. You declare Actions in a JSON file known as the Action package, which you later upload to your developer project when you want to test or submit your Actions project for approval.
To define Actions in your Action package, you create an intent that defines how the Action is invoked and the corresponding fulfillment endpoint for when the intent is triggered. You can create the following types of Actions:
- Default Action: Every Actions project must have a welcome intent that acts
as an entry point for users to start conversations. The welcome intent is
triggered when users explicitly invoke an Action by uttering its name (for
example, "Ok Google, talk to Sekai"). This welcome intent is identified with
the
actions.intent.MAIN
intent name. - Additional Actions for deep-linking: You can create additional Actions in your Action package with intents that you define yourself. This allows users to invoke specific functionality by saying an Action name along with an intent (for example: "Ok Google, talk to Sekai to find some shoes").
See Invocation and Discovery for more information on how these invocation models work.
Define a default Action
Every Action package must have one and only one intent that handles the
actions.intent.MAIN
intent. This intent is triggered when users invoke your
Action by name (for example, "Ok Google, talk to Sekai").
{ "actions": [ { "description": "Default Welcome Intent", "name": "MAIN", "fulfillment": { "conversationName": "sekaiApp" }, "intent": { "name": "actions.intent.MAIN", "trigger": { "queryPatterns": [ "talk to sekaiApp" ] } } } ], "conversations": { "sekaiApp": { "name": "sekaiApp", "url": "https://sekai.example.com/sekaiApp" } }, "locale": "en" }
Define additional Actions
You can provide additional Actions that act as entry points. This lets users disambiguate their intent by letting them specify more details about what they want to do (for example, "Ok Google, talk to Sekai to find me some shoes.").
To define additional Actions:
-
In the
For example, the following sample shows an additional "buy" Action that defines:actions
array, specify an Action for every entry point.- An intent name of
com.example.sekai.BUY
parameters
to parse from the user input when this intent is triggered. This is useful if you need specific data from the Action phrase when users invoke the Action.queryPatterns
that define what users need to say to trigger the intent, which can include Schema.org types that define parameters to parse.
{ "description": "Direct access", "name": "BUY", "fulfillment": { "conversationName": "sekaiApp" }, "intent": { "name": "com.example.sekai.BUY", "parameters": [ { "name": "color", "type": "org.schema.type.Color" } ], "trigger": { "queryPatterns": [ "find some $org.schema.type.Color:color sneakers", "buy some blue suede shoes", "get running shoes" ] } } }
- An intent name of
-
Specify the fulfillment for this intent by specifying a
conversationName
that corresponds to an item in theconversations
object.{ "conversations": { "sekaiApp": { "name": "sekaiApp", "url": "https://sekai.example.com/sekaiApp" } } }
Here's an example of a full Action package:
{ "actions": [ { "description": "Default Welcome Intent", "name": "MAIN", "fulfillment": { "conversationName": "sekaiApp" }, "intent": { "name": "actions.intent.MAIN", "trigger": { "queryPatterns": [ "talk to sekaiApp" ] } } }, { "description": "Direct access", "name": "BUY", "fulfillment": { "conversationName": "sekaiApp" }, "intent": { "name": "com.example.sekai.BUY", "parameters": [ { "name": "color", "type": "org.schema.type.Color" } ], "trigger": { "queryPatterns": [ "find some $org.schema.type.Color:color sneakers", "buy some blue suede shoes", "get running shoes" ] } } } ], "conversations": { "sekaiApp": { "name": "sekaiApp", "url": "https://sekai.example.com/sekaiApp" } }, "locale": "en" }