我打算通过它的号码请求银行帐户信息。我只尝试了一个插槽,AMAZON.Number
但如果帐号是***012345
,Alexa 会将其理解为***012337
(最后两位数字错误)。所以,现在我用五个插槽为这个(numberA
,numberB
,numberC
,numberD
并且numberE
,所有这些都AMAZON.Number
)和CONCAT它们的值(和伟大工程)。
我的json模型:
{
"name": "GetAccountInfo_Intent",
"slots": [
{
"name": "question",
"type": "TYPE_getRequest"
},
{
"name": "owner",
"type": "TYPE_owner"
},
{
"name": "accountByNumber",
"type": "TYPE_accountByNumber"
},
{
"name": "numberA",
"type": "AMAZON.NUMBER"
},
{
"name": "numberB",
"type": "AMAZON.NUMBER"
},
{
"name": "numberC",
"type": "AMAZON.NUMBER"
},
{
"name": "numberD",
"type": "AMAZON.NUMBER"
},
{
"name": "numberE",
"type": "AMAZON.NUMBER"
}
],
"samples": [
"{owner} {accountByNumber} {numberA} {numberB} {numberC} {numberD} {numberE}",
"{accountByNumber} {owner} {numberA} {numberB} {numberC} {numberD} {numberE}",
"{accountByNumber} {numberA} {numberB} {numberC} {numberD} {numberE}",
"{question} {accountByNumber} {numberA} {numberB} {numberC} {numberD} {numberE}",
"{question} {owner} {accountByNumber} {numberA} {numberB} {numberC} {numberD} {numberE}",
"{question} {accountByNumber} {owner} {numberA} {numberB} {numberC} {numberD} {numberE}"
]
},
我希望与 Alexa 的对话是这样的:
我:获取我的账号 ***012345。
Alexa:您是否从帐号***012345 请求信息?
我:是的。
Alexa:你想要所有信息,只是 IBAN 还是银行名称?
我:只是银行。
Alexa:您的编号为 ***012345 的帐户属于 XPTO 银行。
我:你能再说一遍吗?
Alexa:您的编号为 ***012345 的帐户属于 XPTO 银行。
所以我已经搜索了很多关于对话管理的内容(如本手册和许多其他链接)。但是如何像我的情况一样请求多个插槽的确认?所有必须检查确认?我该如何解决这个问题?我的情况有一些很好的例子吗?
我的 lambda 代码:
"GetAccountInfo_Intent": function ()
{
var intent = this;
var number1Value = getSlotValue(intent.event.request.intent, "numberA");
var number2Value = getSlotValue(intent.event.request.intent, "numberB");
var number3Value = getSlotValue(intent.event.request.intent, "numberC");
var number4Value = getSlotValue(intent.event.request.intent, "numberD");
var number5Value = getSlotValue(intent.event.request.intent, "numberE");
var value = number1Value;
if(value == null)
value = number2Value;
else if(number2Value != null)
value += number2Value;
if(value == null)
value = number3Value;
else if(number3Value != null)
value += number3Value;
if(value == null)
value = number4Value;
else if(number4Value != null)
value += number4Value;
if(value == null)
value = number5Value;
else if(number5Value != null)
value += number5Value;
var updatedIntent = this.event.request.intent;
if (this.event.request.dialogState === 'STARTED')
{
this.response.speak("dialogState STARTED");
this.emit(':delegate', updatedIntent);
}
else if (this.event.request.dialogState != 'COMPLETED')
{
if(value == null)
this.emit(':elicitSlot', "numberA", "What are the account number you pretend?", "You must provide a account number. What are the account number you pretend?");
else
this.emit(':delegate', updatedIntent);
}
else
{
if(this.event.request.intent.confirmationStatus == 'CONFIRMED'){
this.response.speak("Your account number are " + value + ".");
this.emit(':responseReady');
}
else{
this.response.speak("Please repeat your account number again.");
this.emit(':responseReady');
}
}
},
我也不明白示例为 lambda 函数显示的逻辑(就像在我的代码中一样)。我怎样才能把this.emit(':elicitSlot')
所有的插槽都做成一个?
在 Alexa Developer Console 上测试这个很糟糕。我无法对此进行调试......它总是说“请求的技能的响应有问题”。