

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

# 在 Lex V2 中匯入和匯出機器人
<a name="importing-exporting"></a>

您可以匯出機器人定義、機器人地區設定或自訂詞彙，然後將其匯入回以建立新的資源或覆寫 AWS 帳戶中的現有資源。例如，您可以從測試帳戶匯出機器人，然後在生產帳戶中建立機器人的副本。您也可以將機器人從一個 AWS 區域複製到另一個區域。

您可以在匯入之前變更匯出資源的資源。例如，您可以匯出機器人，然後編輯插槽的 JSON 檔案，以新增或移除特定插槽的槽值引出表達用語。完成編輯定義後，您可以匯入修改過的檔案。

**Topics**
+ [從 Lex V2 匯出機器人](export.md)
+ [在 Lex V2 中匯入機器人](import.md)
+ [匯入或匯出時使用密碼](import-export-password.md)
+ [在 Lex V2 中匯入和匯出機器人的 JSON 格式](import-export-format.md)

# 從 Lex V2 匯出機器人
<a name="export"></a>

您可以使用 主控台或 `CreatExport`操作匯出機器人、機器人地區設定或自訂詞彙。您可以指定要匯出的資源，並提供選用的密碼，以協助在啟動匯出時保護 .zip 檔案。下載 .zip 檔案之後，您必須使用密碼來存取檔案，才能使用它。如需詳細資訊，請參閱[匯入或匯出時使用密碼](import-export-password.md)。

匯出是非同步操作。開始匯出後，您可以使用 主控台或 `DescribeExport`操作來監控匯出的進度。匯出完成後， 主控台或 `DescribeExport`操作會顯示 狀態`COMPLETED`，而 主控台會將匯出的 .zip 檔案下載至您的瀏覽器。如果您使用 `DescribeExport`操作，Amazon Lex V2 會提供預先簽章的 Amazon S3 URL，您可以在其中下載匯出結果。下載 URL 只能使用五分鐘，但您可以透過再次呼叫 `DescribeExport`操作來取得新的 URL。

您可以使用 主控台或 `ListExports`操作查看資源的匯出歷史記錄。結果會顯示匯出及其目前狀態。匯出可在歷史記錄中使用七天。

當您匯出機器人`Draft`版本或機器人地區設定時，JSON 檔案中的定義可能會處於不一致的狀態，因為機器人`Draft`版本或機器人地區設定可以在匯出進行時變更。如果在匯出時變更`Draft`版本，則變更可能不會包含在匯出檔案中。

匯出機器人地區設定時，Amazon Lex 會匯出定義地區設定的所有資訊，包括地區設定、自訂詞彙、意圖、槽類型和槽。

匯出機器人時，Amazon Lex 會匯出為機器人定義的所有地區設定，包括意圖、槽類型和槽。下列項目不會使用機器人匯出：
+ 機器人別名
+ 與機器人相關聯的角色 ARN
+ 與機器人和機器人別名相關聯的標籤
+ 與機器人別名相關聯的 Lambda 程式碼掛鉤

當您匯入機器人時，角色 ARN 和標籤會輸入為請求參數。您需要建立機器人別名，並視需要在匯入後指派 Lambda 程式碼掛鉤。

您可以使用 主控台或 `DeleteExport`操作來移除匯出和相關聯的 .zip 檔案。

如需使用主控台匯出機器人的範例，請參閱 [匯出 Lex V2 機器人 （主控台）](export-console.md)。

## 在 Lex V2 中匯出機器人所需的 IAM 許可
<a name="export-permissions"></a>

若要匯出機器人、機器人地區設定和自訂詞彙，執行匯出的使用者必須具有下列 IAM 許可。


| API |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/export.html) | 資源 | 
| --- | --- | --- | 
| [CreateExport](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateExport.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/export.html) | 機器人 | 
| [UpdateExport](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_UpdateExport.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/export.html) | 機器人 | 
| [DescribeExport](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_DescribeExport.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/export.html) | 機器人 | 
| 自訂詞彙的 [DescribeExport](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_DescribeExport.html)  | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/export.html)  | 機器人 | 
| [DeleteExport](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_DeleteExport.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/export.html) | 機器人 | 
| [ListExports](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_ListExports.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/export.html) | \$1 | 

如需 IAM 政策範例，請參閱 [允許使用者匯出機器人和機器人地區設定](security_iam_id-based-policy-examples.md#security_iam_id-based-policy-examples-export)。

# 匯出 Lex V2 機器人 （主控台）
<a name="export-console"></a>

您可以從機器人清單、版本清單或版本詳細資訊頁面匯出機器人。當您選擇版本時，Amazon Lex V2 會匯出該版本。下列指示假設您開始從機器人清單匯出機器人，但從版本開始，步驟相同。

**使用主控台匯出機器人**

1. 登入 AWS 管理主控台，並在 [https://console.aws.amazon.com/lexv2/home](https://console.aws.amazon.com/lexv2/home)：// 開啟 Amazon Lex V2 主控台。

1. 從機器人清單中，選擇要匯出的機器人。

1. 在**動作**中，選擇**匯出**。

1. 選擇機器人版本、平台和匯出格式。

1. （選用） 輸入 .zip 檔案的密碼。提供密碼有助於保護輸出封存。

1. 選擇 **Export** (匯出)。

開始匯出後，您會返回機器人清單。若要監控匯出進度，請使用**匯入/匯出歷史記錄**清單。匯出狀態為**完成**時，主控台會自動將 .zip 檔案下載至您的電腦。

若要再次下載匯出，請在匯入/匯出清單中，選擇匯出，然後選擇**下載**。您可以為下載的 .zip 檔案提供密碼。

**匯出機器人語言**

1. 登入 AWS 管理主控台，並在 [https://console.aws.amazon.com/lexv2/home](https://console.aws.amazon.com/lexv2/home)：// 開啟 Amazon Lex V2 主控台。

1. 從機器人清單中，選擇您要匯出其語言的機器人。

1. 在**新增語言**中，選擇**檢視語言**。

1. 從**所有語言**清單中，選擇要匯出的語言。

1. 在**動作**中，選擇**匯出**。

1. 選擇機器人版本、平台和格式。

1. （選用） 輸入 .zip 檔案的密碼。提供密碼有助於保護輸出封存。

1. 選擇 **Export** (匯出)。

開始匯出後，您會返回語言清單。若要監控匯出進度，請使用**匯入/匯出歷史記錄**清單。匯出狀態為**完成**時，主控台會自動將 .zip 檔案下載至您的電腦。

若要再次下載匯出，請在匯入/匯出清單中，選擇匯出，然後選擇**下載**。您可以為下載的 .zip 檔案提供密碼。

# 在 Lex V2 中匯入機器人
<a name="import"></a>

若要使用 主控台匯入先前匯出的機器人、機器人地區設定或自訂詞彙，請在本機電腦上提供檔案位置和選用密碼以解除鎖定檔案。如需範例，請參閱 [匯入 Lex V2 機器人 （主控台）](import-console.md)。

當您使用 API 時，匯入資源是三個步驟：

1. 使用 `CreateUploadUrl`操作建立上傳 URL。使用主控台時，您不需要建立上傳 URL。

1. 上傳包含資源定義的 .zip 檔案。

1. 使用 `StartImport`操作開始匯入。

上傳 URL 是具有寫入許可的預先簽章 Amazon S3 URL。此 URL 會在產生後五分鐘內可用。如果您使用密碼保護 .zip 檔案，您必須在開始匯入時提供密碼。如需詳細資訊，請參閱[匯入或匯出時使用密碼](import-export-password.md)。

匯入是非同步程序。您可以使用 主控台或 `DescribeImport`操作來監控匯入的進度。

當您匯入機器人或機器人地區設定時，匯入檔案中的資源名稱與 Amazon Lex V2 中現有的資源名稱之間可能會有衝突。Amazon Lex V2 可以透過三種方式處理衝突：
+ **衝突時失敗** – 匯入會停止，而且不會從匯入 .zip 檔案匯入任何資源。
+ **覆寫** – Amazon Lex V2 會從匯入 .zip 檔案匯入所有資源，並將任何現有資源取代為匯入檔案中的定義。
+ **附加** – Amazon Lex V2 會從匯入 .zip 檔案匯入所有資源，並新增至具有匯入檔案定義的任何現有資源。這僅適用於機器人地區設定。

您可以使用 主控台或 `ListImports`操作查看資源的匯入清單。匯入會保留在清單中七天。您可以使用 主控台或 `DescribeImport`操作來查看特定匯入的詳細資訊。

您也可以使用 主控台或 `DeleteImport`操作移除匯入和相關聯的 .zip 檔案。

如需使用主控台匯入機器人的範例，請參閱 [匯入 Lex V2 機器人 （主控台）](import-console.md)。

## 匯入所需的 IAM 許可
<a name="import-permissions"></a>

若要匯入機器人、機器人地區設定和自訂詞彙，執行匯入的使用者必須具有下列 IAM 許可。


| API | 必要的 IAM 動作 | 資源 | 
| --- | --- | --- | 
| [CreateUploadUrl](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateUploadUrl.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/import.html) | \$1 | 
| 機器人和機器人地區設定的 [StartImport](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_StartImport.html)  | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/import.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/import.html) | 
| 自訂詞彙的 [StartImport](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_StartImport.html)  | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/import.html)  | 機器人 | 
| [DescribeImport](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_DescribeImport.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/import.html) | 機器人 | 
| [DeleteImport](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_DeleteImport.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/import.html) | 機器人 | 
| [ListImports](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_ListImports.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/import.html) | \$1 | 

如需 IAM 政策範例，請參閱 [允許使用者匯入機器人和機器人地區設定](security_iam_id-based-policy-examples.md#security_iam_id-based-policy-examples-import)。

# 匯入 Lex V2 機器人 （主控台）
<a name="import-console"></a>

**使用主控台匯入機器人**

1. 登入 AWS 管理主控台，並在 [https://console.aws.amazon.com/lexv2/home](https://console.aws.amazon.com/lexv2/home)：// 開啟 Amazon Lex V2 主控台。

1. 從**動作**中，選擇**匯入**。

1. 在**輸入檔案中**，為機器人命名，然後選擇包含定義機器人之 JSON 檔案的 .zip 檔案。

1. 如果 .zip 檔案受密碼保護，請輸入 .zip 檔案的密碼。保護封存的密碼是選用的，但有助於保護內容。

1. 建立或輸入定義機器人許可的 IAM 角色。

1. 指出您的機器人是否受到兒童線上隱私權保護法 (COPPA) 的約束。

1. 為您的機器人提供閒置逾時設定。如果您未提供值，則會使用 zip 檔案中的值。如果 .zip 檔案不包含逾時設定，Amazon Lex V2 會使用預設值 300 秒 (5 分鐘）。

1. （選用） 為您的機器人新增標籤。

1. 選擇是否警告覆寫具有相同名稱的現有機器人。如果您啟用警告，如果您匯入的機器人會覆寫現有的機器人，您會收到警告，而且不會匯入機器人。如果您停用警告，匯入的機器人會以相同的名稱取代現有的機器人。

1. 選擇**匯入**。

開始匯入後，您會返回機器人清單。若要監控匯入的進度，請使用**匯入/匯出歷史記錄**清單。當匯入狀態為**完成**時，您可以從機器人清單中選擇機器人，以修改或建置機器人。

**匯入機器人語言**

1. 登入 AWS 管理主控台，並在 https：//[https://console.aws.amazon.com/lexv2/home](https://console.aws.amazon.com/lexv2/home) 開啟 Amazon Lex V2 主控台。

1. 從機器人清單中，選擇您要匯入語言的機器人。

1. 在**新增語言**中，選擇**檢視語言**。

1. 從**動作**中，選擇**匯入**。

1. 在**輸入檔案中**，選擇包含要匯入之語言的檔案。如果您保護 .zip 檔案，請在密碼中提供**密碼**。

1. 在**語言**中，選擇要匯入的語言。語言不需要符合匯入檔案中的語言。您可以將意圖從一種語言複製到另一種語言。

1. 在**語音**中，選擇要用於語音互動的 Amazon Polly 語音，或對純文字機器人選擇**無**。

1. 在**可信度分數閾值**中，輸入傳回替代意圖時 Amazon Lex V2 插入 `AMAZON.FallbackIntent`、 `AMAZON.KendraSearchIntent`或兩者的閾值。

1. 選擇是否要警告覆寫現有語言。如果您啟用警告，如果您匯入的語言會覆寫現有的語言，您會收到警告，而且不會匯入語言。如果您停用警告，匯入的語言會取代現有的語言。

1. 選擇**匯入**以開始匯入語言。

開始匯入後，您會返回語言清單。若要監控匯入的進度，請使用**匯入/匯出歷史記錄**清單。當匯入狀態為**完成**時，您可以從機器人清單中選擇語言，以修改或建置機器人。

# 匯入或匯出時使用密碼
<a name="import-export-password"></a>

Amazon Lex V2 可以使用標準 .zip 檔案壓縮，以密碼保護匯出封存或讀取受保護的匯入封存。您應該一律使用密碼保護匯入和匯出封存。

Amazon Lex V2 會將匯出封存傳送至 S3 儲存貯體，而且您可以使用預先簽章的 S3 URL 來取得。此 URL 僅在五分鐘內可用。封存可供有權存取下載 URL 的任何人使用。為了協助保護封存中的資料，請在匯出資源時提供密碼。如果您需要在 URL 過期後取得封存，您可以使用 主控台或 `DescribeExport`操作來取得新的 URL。

如果您遺失匯出封存的密碼，您可以為現有檔案建立新密碼，方法是從匯入/匯出歷史記錄資料表中選擇**下載**，或使用 `UpdateExport`操作。如果您在歷史記錄表中選擇**下載**以進行匯出，但未提供密碼，Amazon Lex V2 會下載未受保護的 zip 檔案。

# 在 Lex V2 中匯入和匯出機器人的 JSON 格式
<a name="import-export-format"></a>

您可以使用包含描述資源部分的 JSON 結構的 .zip 檔案，從 Amazon Lex V2 匯入和匯出機器人、機器人地區設定或自訂詞彙。當您匯出資源時，Amazon Lex V2 會建立 .zip 檔案，並使用 Amazon S3 預先簽章的 URL 供您使用。匯入資源時，您必須建立包含 JSON 結構的 .zip 檔案，並將其上傳至 S3 預先簽章的 URL。

當您匯出機器人時，Amazon Lex 會在 .zip 檔案中建立下列目錄結構。匯出機器人地區設定時，只會匯出地區設定下的結構。匯出自訂詞彙時，只會匯出自訂詞彙下的結構。

```
BotName_BotVersion_ExportID_LexJson.zip
            -or-
BotName_BotVersion_LocaleId_ExportId_LEX_JSON.zip
        --> manifest.json
        --> BotName
        ----> Bot.json
        ----> BotLocales
        ------> Locale_A
        --------> BotLocale.json
        --------> Intents
        ----------> Intent_A
        ------------> Intent.json
        ------------> Slots
        --------------> Slot_A
        ----------------> Slot.json
        --------------> Slot_B
        ----------------> Slot.json
        ----------> Intent_B
                       ...
        --------> SlotTypes
        ----------> SlotType_A
        ------------> SlotType.json
        ----------> SlotType_B
                        ...
        --------> CustomVocabulary
        ------------> CustomVocabulary.json

        ------> Locale_B
                        ...
```

## 資訊清單檔案結構
<a name="json-manifest"></a>

資訊清單檔案包含匯出檔案的中繼資料。

```
{
    "metadata": {
        "schemaVersion": "1.0",
        "fileFormat": "LexJson",
        "resourceType": "Bot | BotLocale | CustomVocabulary"
    }
}
```

## 機器人檔案結構
<a name="json-bot"></a>

機器人檔案包含機器人的組態資訊。

```
{
    "name": "BotName",
    "identifier": "identifier",
    "version": "number",
    "description": "description",
    "dataPrivacy": {
        "childDirected": true | false
    },
    "idleSessionTTLInSeconds": seconds
}
```

## 機器人地區設定檔案結構
<a name="json-bot-locale"></a>

機器人地區設定檔案包含機器人地區設定或語言的說明。匯出機器人時，.zip 檔案中可以有多個機器人地區設定檔案。匯出機器人地區設定時， zip 檔案中只有一個地區設定。

```
{
    "name": "locale name",
    "identifier": "locale ID",
    "version": "number",
    "description": "description",
    "voiceSettings": {
        "voiceId": "voice",
        "engine": "standard | neural
    },
    "nluConfidenceThreshold": number
}
```

## 意圖檔案結構
<a name="json-intent"></a>

意圖檔案包含意圖的組態資訊。.zip 檔案中有一個意圖檔案，用於特定地區設定中的每個意圖。

以下是 BookTrip 機器人範例中 BookCar 意圖的 JSON 結構範例。如需意圖 JSON 結構的完整範例，請參閱 [CreateIntent](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateIntent.html) 操作。

```
{
    "name": "BookCar",
    "identifier": "891RWHHICO",
    "description": "Intent to book a car.",
    "parentIntentSignature": null,
    "sampleUtterances": [
        {
            "utterance": "Book a car"
        },
        {
            "utterance": "Reserve a car"
        },
        {
            "utterance": "Make a car reservation"
        }
    ],
    "intentConfirmationSetting": {
        "confirmationPrompt": {
            "messageGroupList": [
                {
                    "message": {
                        "plainTextMessage": {
                            "value": "OK, I have you down for a {CarType} hire in {PickUpCity} from {PickUpDate} to {ReturnDate}.  Should I book the reservation?"
                        },
                        "ssmlMessage": null,
                        "customPayload": null,
                        "imageResponseCard": null
                    },
                    "variations": null
                }
            ],
            "maxRetries": 2
        },
        "declinationResponse": {
            "messageGroupList": [
                {
                    "message": {
                        "plainTextMessage": {
                            "value": "OK, I have cancelled your reservation in progress."
                        },
                        "ssmlMessage": null,
                        "customPayload": null,
                        "imageResponseCard": null
                    },
                    "variations": null
                }
            ]
        }
    },
    "intentClosingSetting": null,
    "inputContexts": null,
    "outputContexts": null,
    "kendraConfiguration": null,
    "dialogCodeHook": null,
    "fulfillmentCodeHook": null,
    "slotPriorities": [
        {
            "slotName": "DriverAge",
            "priority": 4
        },
        {
            "slotName": "PickUpDate",
            "priority": 2
        },
        {
            "slotName": "ReturnDate",
            "priority": 3
        },
        {
            "slotName": "PickUpCity",
            "priority": 1
        },
        {
            "slotName": "CarType",
            "priority": 5
        }
    ]
}
```

## 插槽檔案結構
<a name="json-slot"></a>

槽檔案包含意圖中槽的組態資訊。對於針對特定地區設定中的意圖定義的每個插槽，.zip 檔案中有一個插槽檔案。

下列範例是插槽的 JSON 結構，可讓客戶選擇想要在 BookTrip 範例機器人的 BookCar 意圖中租用的汽車類型。 BookTrip 如需插槽 JSON 結構的完整範例，請參閱 [CreateSlot](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateSlot.html) 操作。

```
{
    "name": "CarType",
    "identifier": "KDHJWNGZGC",
    "description": "Type of car being reserved.",
    "multipleValuesSetting": {
        "allowMutlipleValues": false
    },
    "slotTypeName": "CarTypeValues",
    "obfuscationSetting": null,
    "slotConstraint": "Required",
    "defaultValueSpec": null,
    "slotValueElicitationSetting": {
        "promptSpecification": {
            "messageGroupList": [
                {
                    "message": {
                        "plainTextMessage": {
                            "value": "What type of car would you like to rent?  Our most popular options are economy, midsize, and luxury"
                        },
                        "ssmlMessage": null,
                        "customPayload": null,
                        "imageResponseCard": null
                    },
                    "variations": null
                }
            ],
            "maxRetries": 2
        },
        "sampleValueElicitingUtterances": null,
        "waitAndContinueSpecification": null,
    }
}
```

下列範例顯示複合插槽的 JSON 結構。

```
{
  "name": "CarType",
  "identifier": "KDHJWNGZGC",
  "description": "Type of car being reserved.",
  "multipleValuesSetting": {
      "allowMutlipleValues": false
  },
  "slotTypeName": "CarTypeValues",
  "obfuscationSetting": null,
  "slotConstraint": "Required",
  "defaultValueSpec": null,
  "slotValueElicitationSetting": {
      "promptSpecification": {
          "messageGroupList": [
              {
                  "message": {
                      "plainTextMessage": {
                          "value": "What type of car would you like to rent?  Our most popular options are economy, midsize, and luxury"
                      },
                      "ssmlMessage": null,
                      "customPayload": null,
                      "imageResponseCard": null
                  },
                  "variations": null
              }
          ],
          "maxRetries": 2
      },
      "sampleValueElicitingUtterances": null,
      "waitAndContinueSpecification": null,
  },
  "subSlotSetting": {
    "slotSpecifications": {
      "firstname": {
        "valueElicitationSetting": {
          "promptSpecification": {
            "allowInterrupt": false,
            "messageGroupsList": [
              {
                "message": {
                  "imageResponseCard": null,
                  "ssmlMessage": null,
                  "customPayload": null,
                  "plainTextMessage": {
                    "value": "please provide firstname"
                  }
                },
                "variations": null
              }
            ],
            "maxRetries": 2,
            "messageSelectionStrategy": "Random"
          },
          "defaultValueSpecification": null,
          "sampleUtterances": [
            {
              "utterance": "my name is {firstName}"
            }
          ],
          "waitAndContinueSpecification": null
        },
        "slotTypeId": "AMAZON.FirstName"
      },
      "eyeColor": {
        "valueElicitationSetting": {
          "promptSpecification": {
            "allowInterrupt": false,
            "messageGroupsList": [
              {
                "message": {
                  "imageResponseCard": null,
                  "ssmlMessage": null,
                  "customPayload": null,
                  "plainTextMessage": {
                    "value": "please provide eye color"
                  }
                },
                "variations": null
              }
            ],
            "maxRetries": 2,
            "messageSelectionStrategy": "Random"
          },
          "defaultValueSpecification": null,
          "sampleUtterances": [
            {
              "utterance": "eye color is {eyeColor}"
            },
            {
              "utterance": "I have eyeColor eyes"
            }
          ],
          "waitAndContinueSpecification": null
        },
        "slotTypeId": "7FEVCB2PQE"
      }
    },
    "expression": "(firstname OR eyeColor)"
  }
}
```

## 槽類型檔案結構
<a name="json-slot-type"></a>

槽類型檔案包含語言或地區設定中使用的自訂槽類型的組態資訊。對於特定地區設定中的每個自訂插槽類型，.zip 檔案中有一個插槽類型檔案。

以下是槽類型的 JSON 結構，列出 BookTrip 範例機器人中可用的汽車類型。如需插槽類型 JSON 結構的完整範例，請參閱 [CreateSlotType](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateSlotType.html) 操作。

```
{
    "name": "CarTypeValues",
    "identifier": "T1YUHGD9ZR",
    "description": "Enumeration representing possible types of cars available for hire",
    "slotTypeValues": [{
        "synonyms": null,
        "sampleValue": {
            "value": "economy"
        }
    }, {
        "synonyms": null,
        "sampleValue": {
            "value": "standard"
        }
    }, {
        "synonyms": null,
        "sampleValue": {
            "value": "midsize"
        }
    }, {
        "synonyms": null,
        "sampleValue": {
            "value": "full size"
        }
    }, {
        "synonyms": null,
        "sampleValue": {
            "value": "luxury"
        }
    }, {
        "synonyms": null,
        "sampleValue": {
            "value": "minivan"
        }
    }],
    "parentSlotTypeSignature": null,
    "valueSelectionSetting": {
        "resolutionStrategy": "TOP_RESOLUTION",
        "advancedRecognitionSetting": {
            "audioRecognitionStrategy": "UseSlotValuesAsCustomVocabulary"
        },
        "regexFilter": null
    }
}
```

下列範例顯示複合插槽類型的 JSON 結構。

```
{
  "name": "CarCompositeType",
  "identifier": "TPA3CC9V",
  "description": null,
  "slotTypeValues": null,
  "parentSlotTypeSignature": null,
  "valueSelectionSetting": {
    "regexFilter": null,
    "resolutionStrategy": "CONCATENATION"
  },
  "compositeSlotTypeSetting": {
    "subSlots": [
      {
        "name": "model",
        "slotTypeId": "MODELTYPEID" # custom slot type Id for model
      },
      {
        "name": "city",
        "slotTypeId": "AMAZON.City"
      },
      {
        "name": "country",
        "slotTypeId": "AMAZON.Country"
      },
      {
        "name": "make",
        "slotTypeId": "MAKETYPEID" # custom slot type Id for make
      }
    ]
  }
}
```

以下是使用自訂文法了解客戶表達用語的槽類型。如需詳細資訊，請參閱[文法槽類型](building-srgs.md)。

```
{
  "name": "custom_grammar",
  "identifier": "7KEAQIQKPX",
  "description": "Slot type using a custom grammar",
  "slotTypeValues": null,
  "parentSlotTypeSignature": null,
  "valueSelectionSetting": null,
  "externalSourceSetting": {
    "grammarSlotTypeSetting": {
      "source": {
        "kmsKeyArn": "arn:aws:kms:Region:123456789012:alias/customer-grxml-key",
        "s3BucketName": "grxml-test",
        "s3ObjectKey": "grxml_files/grammar.grxml"
      }
    }
  }
}
```

## 自訂詞彙檔案結構
<a name="json-custom-vocab"></a>

自訂詞彙檔案包含單一語言或地區設定之自訂詞彙中的項目。每個具有自訂詞彙的地區設定在 .zip 檔案中有一個自訂詞彙檔案。

以下是接受餐廳訂單之機器人的自訂詞彙檔案。機器人中的每個地區設定都有一個檔案。

```
{
    "customVocabularyItems": [
        {
            "weight": 3,
            "phrase": "wafers"
        },
        {
            "weight": null,
            "phrase": "extra large"
        },
        {
            "weight": null,
            "phrase": "cremini mushroom soup"
        },
        {
            "weight": null,
            "phrase": "ramen"
        },
        {
            "weight": null,
            "phrase": "orzo"
        }
    ]
}
```