本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
在 Lex V2 中匯入和匯出機器人的 JSON 格式
您可以使用包含描述資源部分的 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"
}
]
}