我正在研究Alexa技能,当我通过LaunchRequest打开技能时,我想将用户重定向到一个意图。
Open xyz skill
this.emit('AnotherIntent')
AnotherIntent
有一个SLOT,这是其运作所必需的。AnotherIntent
在自行调用时可以正常工作。但是,当我启动该技能并尝试从上面的步骤2中提到的AnotherIntent
内调用时,Alexa技能无法启动。
还有一点需要注意的是,当我在技能构建器中为此场景测试相同的Alexa技能时,输出json正确地向我显示了引出的SLOT。当我尝试从Echo设备运行它时,不确定发生了什么。
我正在使用NodeJS和Lambda来部署我的Alexa处理程序。
任何帮助都将不胜感激。
基于评论的进一步参考 -
处理程序 -
var handlers = {
'LaunchRequest': function () {
console.log("LaunchRequest::" + JSON.stringify(this.event.request));
this.emit('fooIntent');
},
'SessionEndedRequest': function () {
console.log('session ended!');
},
'fooIntent': function () {
const intentObj = this.event.request.intent;
if (!intentObj || (intentObj && !intentObj.slots.WHEN.value)) {
console.log('fooIntent::UserId' + this.event.session.user.userId);
const slotToElicit = 'WHEN';
const speechOutput = 'Ask a question here ?';
const repromptSpeech = speechOutput;
console.log("emitting elict now");
this.emit(':elicitSlot', slotToElicit, speechOutput, repromptSpeech);
} else {
// SLOT is filled, let's query the database to get the value for the slot.
console.log("fooIntent intent:something is requested for " + this.event.request.intent.slots.WHEN.value);
// All the slots are filled (And confirmed if you choose to confirm slot/intent)
fooIntentFunction(this,this.event.request.intent.slots.WHEN.value);
}
},
'AMAZON.HelpIntent': function () {
var speechOutput = "Need to come up with one.";
var reprompt = "What can I help you with?";
this.emit(':ask', speechOutput, reprompt);
},
'AMAZON.CancelIntent': function () {
this.emit(':tell', 'Goodbye!');
},
'AMAZON.StopIntent': function () {
this.emit(':tell', 'Goodbye!');
}
};
在LaunchRequest中捕获的JSON请求
{
"type": "LaunchRequest",
"requestId": "amzn1.echo-api.request.972bb705-d181-495e-bf60-991f2bd8fbb1",
"timestamp": "2017-12-30T21:35:21Z",
"locale": "en-US"
}
从LaunchRequest调用时在Intent中捕获的JSON请求。它表明intent
未设置。我相信这就是为什么当我尝试在fooIntent实现中发出elicit时它会一直失败的原因如上所示。
{
"type": "LaunchRequest",
"requestId": "amzn1.echo-api.request.972bb705-d181-495e-bf60-991f2bd8fbb1",
"timestamp": "2017-12-30T21:35:21Z",
"locale": "en-US"
}
答案 0 :(得分:2)
如Amazon's documentation中所述,对话框界面用于填充特定意图的所有必需插槽:
问题和答案旨在收集并确认所有意图所需插槽的值。会话继续进行,直到意图所需的所有插槽都被填充并确认。
在您的情况下,用户的请求不是意图(即IntentRequest
类型),而是LaunchRequest
。因此,它没有交互模型,也没有引出的槽,即使它是由意图处理程序处理的。
您应该通过深度调用(例如
)让您的技能按预期工作Alexa,告诉xyz技能让我成为三明治
(如果三明治意图,或者在您的情况下为fooIntent
,则有一个WHEN
位置来引出)。
希望这有帮助!
答案 1 :(得分:0)
尝试一下
this.emitWithState("IntentName");
希望这会有所帮助。一切顺利:)
答案 2 :(得分:0)
使用以下代码片段可以简单地从另一个意图调用一个意图:\ this.emit(“意图名称”)
在第一个意图的响应中,输入您要调用的意图的名称。