Formato JSON per l'importazione e l'esportazione - Amazon Lex

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Formato JSON per l'importazione e l'esportazione

Puoi importare ed esportare bot, versioni locali dei bot o vocabolari personalizzati da Amazon Lex V2 utilizzando un file.zip che contiene strutture JSON che descrivono le parti della risorsa. Quando esporti una risorsa, Amazon Lex V2 crea il file.zip e lo rende disponibile utilizzando un URL prefirmato Amazon S3. Quando importi una risorsa, devi creare un file.zip che contenga le strutture JSON e caricarlo su un URL prefirmato S3.

Amazon Lex crea la seguente struttura di directory nel file.zip quando esporti un bot. Quando esporti le impostazioni locali di un bot, viene esportata solo la struttura sotto la lingua. Quando si esporta un vocabolario personalizzato, viene esportata solo la struttura sotto il vocabolario personalizzato.

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 ...

Struttura del file manifest

Il file manifest contiene i metadati per il file di esportazione.

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

Struttura dei file bot

Il file bot contiene le informazioni di configurazione per il bot.

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

Struttura dei file locali dei bot

Il file locale del bot contiene una descrizione delle impostazioni locali o della lingua di un bot. Quando esporti un bot, può esserci più di un file locale del bot nel file.zip. Quando esporti le impostazioni locali di un bot, nel file zip è presente una sola lingua.

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

Struttura del file di intento

Il file di intento contiene le informazioni di configurazione per un intento. Nel file.zip è presente un file di intenti per ogni intento in una lingua specifica.

Di seguito è riportato un esempio di struttura JSON per l'BookCarintento nel bot di esempioBookTrip. Per un esempio completo della struttura JSON per un intento, vedere l'CreateIntentoperazione.

{ "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 } ] }

Struttura del file Slot

Il file slot contiene le informazioni di configurazione per uno slot in un intento. C'è un file slot nel file.zip per ogni slot definito per un intento in una lingua specifica.

L'esempio seguente è la struttura JSON di uno slot che consente al cliente di scegliere il tipo di auto che desidera noleggiare nell'BookCarintento del bot di BookTrip esempio. Per un esempio completo della struttura JSON per uno slot, vedere l'CreateSlotoperazione.

{ "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, } }

L'esempio seguente mostra la struttura JSON di uno slot composito.

{ "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)" } }

Struttura del file di tipo slot

Il file del tipo di slot contiene le informazioni di configurazione per un tipo di slot personalizzato utilizzato in una lingua o in una lingua. C'è un file di tipo di slot nel file.zip per ogni tipo di slot personalizzato in una lingua specifica.

Di seguito è riportata la struttura JSON per il tipo di slot che elenca i tipi di auto disponibili nel bot di BookTrip esempio. Per un esempio completo della struttura JSON per un tipo di slot, vedere l'CreateSlotTypeoperazione.

{ "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 } }

L'esempio seguente mostra la struttura JSON per un tipo di slot composito.

{ "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 } ] } }

Quello che segue è un tipo di slot che utilizza una grammatica personalizzata per comprendere le espressioni del cliente. Per ulteriori informazioni, consulta Tipo di slot grammaticale.

{ "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" } } } }

Struttura dei file di vocabolario personalizzata.

Il file di vocabolario personalizzato contiene le voci di un vocabolario personalizzato per una sola lingua o locale. C'è un file di vocabolario personalizzato nel file.zip per ogni lingua con un vocabolario personalizzato.

Quello che segue è un file di vocabolario personalizzato per un bot che accetta ordini al ristorante. C'è un file per ogni lingua nel bot.

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