本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
JSON在 Lex V2 中匯入和匯出機器人的格式
您可以使用包含描述資源各部分之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
...
清單檔案結構
資訊清單檔案包含匯出檔案的中繼資料。
{ "metadata": { "schemaVersion": "1.0", "fileFormat": "LexJson", "resourceType": "
Bot
|BotLocale
|CustomVocabulary
" } }
機器人檔案結構
機器人檔案包含機器人的組態資訊。
{ "name": "
BotName
", "identifier": "identifier
", "version": "number
", "description": "description
", "dataPrivacy": { "childDirected":true
|false
}, "idleSessionTTLInSeconds":seconds
}
機器人地區設定檔案
機器人地區設定檔案包含機器人地區設定或語言的描述。當您匯出機器人時,.zip 檔案中可能會有多個機器人地區設定檔案。當您匯出機器人地區設定時,zip 檔案中只有一個地區設定。
{ "name": "
locale name
", "identifier": "locale ID
", "version": "number
", "description": "description
", "voiceSettings": { "voiceId": "voice
", "engine": "standard | neural
}, "nluConfidenceThreshold":number
}
意圖文件結構
意圖檔案包含意圖的組態資訊。在特定地區設定中,.zip 檔案中的每個意圖都有一個意圖檔案。
以下是範例 BookTrip 機器人中 BookCar 意圖的JSON結構範例。如需意圖JSON結構的完整範例,請參閱CreateIntent作業。
{ "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 } ] }
插槽文件結構
槽檔案包含意圖中槽的組態資訊。在 .zip 檔案中,針對特定語言環境中的意圖而定義的每個插槽,都有一個插槽檔案。
下列範例是插槽的JSON結構,可讓客戶在範 BookTrip 例機器人中選擇想要租用的 BookCar 汽車類型。如需插槽JSON結構的完整範例,請參閱CreateSlot操作。
{ "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)" } }
插槽類型檔案結構
插槽類型檔案包含語言或地區設定中使用的自訂插槽類型的組態資訊。在特定地區設定中,.zip 檔案中的每個自訂插槽類型都有一個插槽類型檔案。
以下是插槽類型的JSON結構,該插槽類型列出了 BookTrip 示例機器人中可用的汽車類型。如需槽類型JSON結構的完整範例,請參閱CreateSlotType操作。
{ "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 } ] } }
以下是一種插槽類型,它使用自定義語法來了解客戶的話語。如需詳細資訊,請參閱文法插槽類型。
{ "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" } } } }
自訂字彙檔案結構
自訂字彙檔案包含單一語言或地區設定的自訂字彙中的項目。每個具有自訂字彙的語言環境的 .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"
}
]
}