首页 > 解决方案 > Alexa技能中的多轮对话错误

问题描述

我创建了一个名为“BuyDog”的技能,它的调用名称是“dog app”

所以这应该意味着,只有在听到调用名称后,我才能使用内部定义的意图。(那是对的吗?)

然后我将带有插槽的意图定义为:

"what is {dog} price."

"Tell me the price of {dog}."

其中插槽{dog}是插槽类型“DogType”。我已根据需要标记此插槽以完成

然后我将端点添加到 AWS lambda 函数中,在该函数中我使用了 node.js 中的 factkills 项目的蓝图代码,并进行了一些小改动以查看其工作情况。

const GET_DOG_PRICE_MESSAGE = "Here's your pricing: ";

const data = [
    'You need to pay $2000.',
    'You need to pay Rs2000.',
    'You need to pay $5000.',
    'You need to pay INR 3000.',

];
const handlers = {
//some handlers.......................
'DogIntent': function () {
        const factArr = data;
        const factIndex = Math.floor(Math.random() * factArr.length);
        const randomFact = factArr[factIndex];
        const speechOutput = GET_DOG_PRICE_MESSAGE + randomFact;
}
//some handlers.......................
};

根据我期待的关于代码

我说:“Alexa 开放狗应用程序”

它应该只是准备好听“什么是{dog}价格”的意图。另一个。data[]相反,它表示来自 node.js 代码数组的随机字符串。在说出 Intent 之后,我期待得到这个响应,因为完成 Intent 需要插槽。 要求

什么时候

我说:“打开狗应用程序,告诉我 XXXX 的价格。”

它要求“哪个品种” (这是我定义的问题)但它工作正常并显示定价

Alexa 说:“这是你的定价:你需要支付 5000 美元。”

(或数据数组中的其他值)用于任何 XXXX(即狗或非狗类型)。 为什么 alexa 不确认这个词是否在 slot set 中? 插槽配置

什么时候

我说:“打开狗皮”。

我预计 alexa 不会理解这个问题,但它给了我一个关于吠叫的事实为什么?那是怎么发生的?
Alexa 是否有一套默认的技能?像搜索谷歌/亚马逊等...

我感到很困惑。请帮助我了解发生了什么?

标签: alexaalexa-skills-kitalexa-skillalexa-voice-serviceavspeechutterance

解决方案


如果您没有完整的代码来确切了解正在发生的事情并提供代码答案,我希望只是对您的问题/问题的解释将为您指明正确的方向。


1.发动技能

我说:“Alexa open dog app”
它应该只是准备好倾听意图......

您希望 Alexa 只是倾听,但实际上,Alexa 会打开您的技能,并希望您此时有一个通用的欢迎响应。Alexa 将向您的 Lambda发送启动请求。这与 an 不同IntentRequest,因此您可以通过检查来确定request.type。通常发现:

this.event.request.type === 'LaunchRequest'

我建议您在 Lambda 中添加一些日志记录,并使用CloudWatch查看来自 Alexa 的传入请求:

console.log("ALEXA REQUEST= " + event)

2.槽值识别

I say: "open the dog app and Tell me the price of XXXX."
Why is alexa not confirming the word is in slot set or not?

Alexa does not limit a slot to the slot values set in the slotType. The values you give the slotType are used as a guide, but other values are also accepted.

It is up to you, in your Lambda Function, to validate those slot values to make sure they are set to a value you accept. There are many ways to do this, so just start by detecting what the slot has been filled with. Usually found with:

this.event.request.intent.slots.{slotName}.value;

If you choose to set up synonyms in the slotType, then Alexa will also provide her recommended slot value resolutions. For example you could inlcude "Rotty" as a synonym for "Rottweiler", and Alexa will fill the slot with "Rotty" but also suggest you to resolve that to "Rottweiler".

var resolutionsArray = this.event.request.intent.slots.{slotName}.resolutions.resolutionsPerAuthority;

Again, use console.log and CloudWatch to view the slot values that Alexa accepts and fills.


3. Purposefully Fail to Launch Skill

I say: "open the dog bark".
I expected alexa to not understand the question but it gave me a fact about barking.

You must be doing this outside of your Skill, where Alexa will take any inputs and try to recognize an enabled skill, or handle with her best guess of default abilities.

Alexa 确实具有默认的内置能力(实际上不是技能)来回答一般问题,并且变得有趣和友好。你可以在这里看到她自己可以做什么:Alexa - 尝试的事情

所以我的猜测是,Alexa 认为您在询问有关狗吠的问题,因此提供了答案。你可以试着问她“什么是狗吠”,看看她的回答是否与“打开狗吠”一模一样,只是为了证实这些怀疑。


要真正了解开发 Alexa 技能,您应该花时间非常熟悉以下文档: Alexa Request and Response JSON Formats


推荐阅读