この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
渡辺です。
東京リージョン対応が待望されるLexですが、スキーマのImport/Export機能がリリースされました。 これまでGUIで操作するだけで不便な部分もありましたが、便利になりますね。
Export
ExportはBot一覧から行います。
フォーマットが2種類ありました。 Lex用のスキーマとAlexa用のスキーマが選べるようです。
Lexフォーマット
設定項目がGUIとほぼリンクしています。
{
"metadata": {
"schemaVersion": "1.0",
"importType": "LEX",
"importFormat": "JSON"
},
"resource": {
"name": "Appointment",
"version": "1",
"intents": [
{
"name": "Reservation",
"version": "3",
"fulfillmentActivity": {
"type": "ReturnIntent"
},
"sampleUtterances": [
"I want to see you.",
"I want reservation."
],
"slots": [
{
"name": "Date",
"slotConstraint": "Required",
"slotType": "AMAZON.DATE",
"valueElicitationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "What day do you want to reserve?"
}
],
"maxAttempts": 2
},
"priority": 1,
"sampleUtterances": []
},
{
"name": "Time",
"slotConstraint": "Required",
"slotType": "AMAZON.TIME",
"valueElicitationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "At what time do you want to reserve?"
}
],
"maxAttempts": 2
},
"priority": 2,
"sampleUtterances": []
}
],
"dialogCodeHook": {
"uri": "arn:aws:lambda:us-east-1:378384917084:function:appointment",
"messageVersion": "1.0"
}
}
],
"voiceId": "0",
"childDirected": false,
"locale": "en-US",
"idleSessionTTLInSeconds": 300,
"clarificationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "Sorry, can you please repeat that?"
}
],
"maxAttempts": 5
},
"abortStatement": {
"messages": [
{
"contentType": "PlainText",
"content": "Sorry, I could not understand. Goodbye."
}
]
}
}
}
Alexaフォーマット
Alexaの発話モデルの形式でエクスポートされます。 LexボットをAlexaに対応させるケースで利用できそうです。
{
"intents": [
{
"name": "Reservation",
"samples": [
"I want to see you.",
"I want reservation."
],
"slots": [
{
"name": "Date",
"type": "AMAZON.DATE",
"samples": []
},
{
"name": "Time",
"type": "AMAZON.TIME",
"samples": []
}
]
}
],
"types": [],
"prompts": [
{
"id": "Elicit.Intent-Reservation.IntentSlot-Date",
"promptVersion": "1.0",
"definitionVersion": "1.0",
"variations": [
{
"type": "PlainText",
"value": "What day do you want to reserve?"
}
]
},
{
"id": "Elicit.Intent-Reservation.IntentSlot-Time",
"promptVersion": "1.0",
"definitionVersion": "1.0",
"variations": [
{
"type": "PlainText",
"value": "At what time do you want to reserve?"
}
]
}
],
"dialog": {
"version": "1.0",
"intents": [
{
"name": "Reservation",
"confirmationRequired": false,
"prompts": {},
"slots": [
{
"name": "Date",
"type": "AMAZON.DATE",
"elicitationRequired": true,
"confirmationRequired": false,
"prompts": {
"elicit": "Elicit.Intent-Reservation.IntentSlot-Date"
}
},
{
"name": "Time",
"type": "AMAZON.TIME",
"elicitationRequired": true,
"confirmationRequired": false,
"prompts": {
"elicit": "Elicit.Intent-Reservation.IntentSlot-Time"
}
}
]
}
]
}
}
Import
インポートも同様にボット一覧から行います。 Alexaフォーマットではインポートできません。
まとめ
LexのスキーマがImport/Exportできるようになりました。 Alexa用のスキーマもExportできるため、設計時にLexで流れの検証を行ったり、LexとAlexaを両対応させたいようなケースでも活用できそうです。