

终止支持通知：2025年9月15日， AWS 我们将停止对Amazon Lex V1的支持。2025 年 9 月 15 日之后，您将无法再访问 Amazon Lex V1 控制台或 Amazon Lex V1 资源。如果您使用的是 Amazon Lex V2，请改为参阅 [Amazon Lex V2 指南](https://docs.aws.amazon.com/lexv2/latest/dg/what-is.html)。

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 步骤 2：创建自定义槽类型 (AWS CLI)
<a name="gs-create-flower-types"></a>

创建一个包含可订购鲜花枚举值的自定义槽类型。在下一步骤中创建 `OrderFlowers` 目的时会用到这一类型。*槽类型* 定义了目的的槽 (参数) 的可能值。

要运行本练习中的命令，您需要知道将在其中运行命令的区域。有关区域列表，请参阅[模型构建配额](gl-limits.md#gl-limits-model-building)。

**创建自定义槽类型 (AWS CLI)**

1. 创建名为 **FlowerTypes.json** 的文本文件。将 JSON 代码从 [FlowerTypes.json](gs-cli-create-flower-types-json.md) 复制到该文本文件中。

1. 使用调用[PutSlotType](API_PutSlotType.md)操作 AWS CLI 来创建插槽类型。此示例的格式适用于 Unix、Linux 和 macOS。对于 Windows，请将每行末尾的反斜杠 (\$1) Unix 行继续符替换为脱字号 (^)。

   ```
   aws lex-models put-slot-type \
       --region region \
       --name FlowerTypes \
       --cli-input-json file://FlowerTypes.json
   ```

   服务器的响应如下：

   ```
   {
       "enumerationValues": [
           {
               "value": "tulips"
           }, 
           {
               "value": "lilies"
           }, 
           {
               "value": "roses"
           }
       ], 
       "name": "FlowerTypes", 
       "checksum": "checksum", 
       "version": "$LATEST", 
       "lastUpdatedDate": timestamp, 
       "createdDate": timestamp, 
       "description": "Types of flowers to pick up"
   }
   ```

## 下一个步骤
<a name="gs-create-next-3"></a>

[步骤 3：创建目的 (AWS CLI)](gs-cli-create-order-flowers.md)

# FlowerTypes.json
<a name="gs-cli-create-flower-types-json"></a>

以下代码是创建 `FlowerTypes` 自定义槽类型所需的 JSON 数据：

```
{
    "enumerationValues": [
        {
            "value": "tulips"
        },
        {
            "value": "lilies"
        },
        {
            "value": "roses"
        }
    ],
    "name": "FlowerTypes",
    "description": "Types of flowers to pick up"
}
```