Actions are entry points into your app that define the [invocation and discovery](https://developers.google.com/assistant/df-asdk/discovery)
model for your app. You declare Actions in a JSON file known as the [Action package](https://developers.google.com/assistant/df-asdk/reference/action-package/rest/Shared.Types/ActionPackage),
which you later upload to your developer project when you want to test or
submit your Actions project for approval. An Action package is a JSON file that
defines the Actions in your Actions project.

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, *"Hey Google, talk to ExampleAction"* ). 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: *"Hey Google, talk to ExampleAction to find some shoes"*).

See [Intents and invocation](https://developers.google.com/assistant/df-asdk/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, *"Hey Google, talk to ExampleAction"*).

> [!NOTE]
> **Note:** You specify your Action name in the project, when you submit your Action package for approval. During testing, you invoke your Action by saying *"talk
> to my test app"*.

To generate a boilerplate Action package file named `action.json`, take the
following steps:

1. Download the [`gactions` CLI](https://developers.google.com/assistant/df-asdk/actions-sdk/gactions-cli).
2. Create a local directory for your Action project's source files.
3. Run the following commands in the terminal:

   ```
   $ cd PROJECT_DIRECTORY
   $ gactions init
   ```

Once the Action package file is generated, replace placeholder content with your
values. Here's an example of `action.json` with changes for `ExampleAction`:

```
{
  "actions": [
    {
      "description": "Default welcome intent",
      "name": "MAIN",
      "fulfillment": {
        "conversationName": "ExampleAction"
      },
      "intent": {
        "name": "actions.intent.MAIN",
        "trigger": {
          "queryPatterns": [
            "talk to ExampleAction"
          ]
        }
      }
    }
  ],
  "conversations": {
    "ExampleAction": {
      "name": "ExampleAction",
      "url": "https://www.example.com/ExampleAction"
    }
  },
  "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, *"Hey Google, talk to ExampleAction to find me some
shoes."*).

To define additional Actions:

1. In the `actions` array, specify an Action for every entry point.

   For example, the following code shows an additional "buy" Action that defines:
   - An intent name of `com.example.ExampleAction.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. [Query patterns](https://developers.google.com/assistant/df-asdk/reference/action-package/QueryPatterns) can include Schema.org types that define parameters to parse.

   ```
   {
     "description": "Direct access",
     "name": "BUY",
     "fulfillment": {
       "conversationName": "ExampleAction"
     },
     "intent": {
       "name": "com.example.ExampleAction.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"
         ]
       }
     }
   }
         
   ```

> [!NOTE]
> Note: We recommend around 10 `queryPatterns` phrases for each intent. These query patterns are used by Google for Action ranking and discovery. They should be representative of your Action's capabilities and indicate how users might want to invoke your Actions.

2. Specify the fulfillment for this intent by specifying a `conversationName`
   that corresponds to an item in the `conversations` object.

   ```
   {
     "conversations": {
       "ExampleAction": {
         "name": "ExampleAction",
         "url": "https://www.example.com/ExampleAction"
       }
     }
   }
       
   ```

> [!NOTE]
> Note: You typically will only need one fulfillment endpoint, but Action packages support many.

Here's an example of a full Action package:

```
{
  "actions": [
    {
      "description": "Default welcome intent",
      "name": "MAIN",
      "fulfillment": {
        "conversationName": "ExampleAction"
      },
      "intent": {
        "name": "actions.intent.MAIN",
        "trigger": {
          "queryPatterns": [
            "talk to ExampleAction"
          ]
        }
      }
    },
    {
      "description": "Direct access",
      "name": "BUY",
      "fulfillment": {
        "conversationName": "ExampleAction"
      },
      "intent": {
        "name": "com.example.ExampleAction.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": {
    "ExampleAction": {
      "name": "ExampleAction",
      "url": "https://www.example.com/ExampleAction"
    }
  },
  "locale": "en"
}
```