

支援終止通知：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)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 步驟四：建立機器人 (AWS CLI)
<a name="gs-cli-create-order-flowers-bot"></a>

`OrderFlowersBot` 機器人有一個意圖，即您在之前的步驟所建立的 `OrderFlowers` 意圖。若要執行本練習中的命令，您必須知道要執行命令的區域。如需區域的列表，請參閱[模型建置配額](gl-limits.md#gl-limits-model-building)。

**注意**  
下列 AWS CLI 範例已針對 Unix、Linux 和 macOS 格式化。用於 Windows 時，請將 `"\$LATEST"` 變更為 `$LATEST`。

**建立 `OrderFlowersBot` 機器人 (AWS CLI)**

1. 建立名為 **OrderFlowersBot.json** 的文字檔案。從 [OrderFlowersBot.json](gs-cli-create-order-flowers-bot-json.md) 複製 JSON 程式碼到文字檔案。

1. 在 中 AWS CLI，呼叫 [PutBot](API_PutBot.md)操作來建立機器人。此範例格式適用於 Unix、Linux 和 macOS。用於 Windows 時，請以插入號 (^) 取代每一行結尾處的 Unix 接續字元斜線 (\$1)。

   ```
   aws lex-models put-bot \
       --region region \
       --name OrderFlowersBot \
       --cli-input-json file://OrderFlowersBot.json
   ```

   伺服器會隨之回應。當建立或更新機器人時，`status` 欄位會設定為 `BUILDING`。這表示機器人尚未準備就緒。若要判斷機器人何時準備就緒，請使用下一步中的 [GetBot](API_GetBot.md) 操作。

   

1. 若要判斷您的新機器人是否已準備就緒，請執行下列命令。重複此命令，直到 `status` 欄位傳回 `READY` 為止。此範例格式適用於 Unix、Linux 和 macOS。用於 Windows 時，請以插入號 (^) 取代每一行結尾處的 Unix 接續字元斜線 (\$1)。

   ```
   aws lex-models get-bot \
       --region region \
       --name OrderFlowersBot \
       --version-or-alias "\$LATEST"
   ```

   在回應中尋找 `status` 欄位：

   ```
   {
       "status": "READY", 
       
       ...
       
   }
   ```

## 後續步驟
<a name="gs-create-next-5"></a>

[步驟 5：測試機器人 (AWS CLI)](gs-create-test.md)

# OrderFlowersBot.json
<a name="gs-cli-create-order-flowers-bot-json"></a>

下列程式碼提供建置 Amazon Lex 機器人所需的 JSON `OrderFlowers` 資料：

```
{
    "intents": [
        {
            "intentVersion": "$LATEST",
            "intentName": "OrderFlowers"
        }
    ],
    "name": "OrderFlowersBot",
    "locale": "en-US",
    "abortStatement": {
        "messages": [
            {
                "content": "Sorry, I'm not able to assist at this time",
                "contentType": "PlainText"
            }
        ]
    },
    "clarificationPrompt": {
        "maxAttempts": 2,
        "messages": [
            {
                "content": "I didn't understand you, what would you like to do?",
                "contentType": "PlainText"
            }
        ]
    },
    "voiceId": "Salli",
    "childDirected": false,
    "idleSessionTTLInSeconds": 600,
    "description": "Bot to order flowers on the behalf of a user"
}
```