

支援終止通知：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-cli-publish-intent"></a>

您必須先發佈意圖所參考的所有槽類型之後，才能發佈意圖。槽類型必須是已編號的版本，而非 `$LATEST` 版本。

首先，更新 `OrderFlowers` 意圖以使用您在前面的步驟中發佈的 `FlowerTypes` 槽類型版本。然後，發佈 `OrderFlowers` 意圖的新版本。

**注意**  
下列 AWS CLI 範例已針對 Unix、Linux 和 macOS 格式化。用於 Windows 時，請將 `"\$LATEST"` 變更為 `$LATEST`，並以插入號 (^) 取代每一行結尾處的反斜線 (\$1) 接續字元。

**發佈意圖的版本 (AWS CLI)**

1. 在 中 AWS CLI，取得`OrderFlowers`意圖的`$LATEST`版本，並將其儲存至 檔案：

   ```
   aws lex-models get-intent \
       --region region \
       --name OrderFlowers \
       --intent-version "\$LATEST" > OrderFlowers_V4.json
   ```

1. 在文字編輯器中，開啟 **OrderFlowers\$1V4.json** 檔案。刪除 `createdDate`、`lastUpdatedDate` 和 `version` 欄位。找出 `FlowerTypes` 槽類型並將版本變更為您在前面的步驟中記錄的版本編號。以下 **OrderFlowers\$1V4.json** 檔案片段顯示變更的位置：

   ```
           {
               "slotType": "FlowerTypes", 
               "name": "FlowerType", 
               "slotConstraint": "Required", 
               "valueElicitationPrompt": {
                   "maxAttempts": 2, 
                   "messages": [
                       {
                           "content": "What type of flowers?", 
                           "contentType": "PlainText"
                       }
                   ]
               }, 
               "priority": 1, 
               "slotTypeVersion": "version", 
               "sampleUtterances": []
           },
   ```

1. 在 中 AWS CLI，儲存意圖的修訂：

   ```
   aws lex-models put-intent \
       --name OrderFlowers \
       --cli-input-json file://OrderFlowers_V4.json
   ```

1. 取得意圖最新修訂版的檢查總和：

   ```
   aws lex-models get-intent \
       --region region \
       --name OrderFlowers \
       --intent-version "\$LATEST" > OrderFlowers_V4a.json
   ```

   以下回應片段顯示意圖的的檢查總和。請將此記錄下來以用於下個步驟。

   ```
       "name": "OrderFlowers", 
       "checksum": "checksum", 
       "version": "$LATEST",
   ```

1. 發佈意圖的新版本：

   ```
   aws lex-models create-intent-version \
       --region region \
       --name OrderFlowers \
       --checksum "checksum"
   ```

   以下回應片段顯示意圖的新版本。記錄版本編號以用於下個步驟。

   ```
       "name": "OrderFlowers", 
       "checksum": "checksum", 
       "version": "version",
   ```

## 後續步驟
<a name="gs-cli-publish-3"></a>

[步驟 3：發佈機器人 (AWS CLI)](gs-cli-publish-bot.md)