简体   繁体   English

Alexa内置插槽类型:无值传递

[英]Alexa Built-In Slot Type: No value being passed

I've been having a heck of a time figuring out how to get the Alexa built-in slots to work properly, and I feel like I must be missing something super fundamental. 我花了很长时间来弄清楚如何使Alexa内置插槽正常工作,而且我觉得我必须缺少一些超级基础知识。 To set things up for you, I'll start on the Testing page of the Developer Portal. 要为您进行设置,我将从开发人员门户的“测试”页面开始。 I'm using node.js 6.10. 我正在使用node.js 6.10。

Under the text utterance service simulator, if I type "I need 5 sleep cycles" it generates a request as such: 在文本语音服务模拟器下,如果键入“我需要5个睡眠周期”,它将生成如下请求:

  "intent": { "name": "SleepCyclesIntent", "slots": { "number": { "name": "number" } } } 

The result is: "text": "I now know that you want NaN sleep cycles." 结果是:“ text”:“我现在知道您想要NaN睡眠周期。” Note the lack of a "value" field being generated from the utterance. 请注意缺少从话语生成的“值”字段。

However, when I manually insert a "value" field in a JSON request, I get the desired output! 但是,当我在JSON请求中手动插入“值”字段时,将获得所需的输出!

 "intent": { "name": "SleepCyclesIntent", "slots": { "number": { "name": "number", "value": "5" } } } 

The result is: "text": "I now know that you want 5 sleep cycles." 结果是:“ text”:“我现在知道您想要5个睡眠周期。”

I had everything set up the the default intents editor before when I was having this issue, and I've since switched over to the beta intents editor, hoping that it would fix whatever I might be doing wrong. 在遇到此问题之前,我已经将所有内容都设置为默认的Intent编辑器,此后我切换到了Beta Intent编辑器,希望它可以解决我可能做错的任何事情。 Over there, under "SleepCyclesIntent" which is sent over to sleep_cycles, I have an utterance "I need {number} sleep cycles", with [number} being a slot type of AMAZON.NUMBER. 在那儿,在发送到sleep_cycles的“ SleepCyclesIntent”下,我说了“我需要{number}个睡眠周期”,其中[number}是AMAZON.NUMBER的插槽类型。

For additional reference, in case it's helpful, here's the related chunk of my code over in Lambda: 作为参考,如果有帮助,请参见Lambda中与代码相关的部分:

 function sleep_cycles(intent, session, callback) { const cardTitle = "Sleep Cycles"; let repromptText = ''; let sessionAttributes = {}; const shouldEndSession = true; let speechOutput = ''; let targetCycles = intent.slots.number.value; speechOutput = "I now know that you want " + targetCycles + " sleep cycles."; 

I apologize if this is a really stupid question, but I've been digging through forums and Amazon's Alexa help and google every day for the past week and I just have no idea where else to turn. 如果这是一个非常愚蠢的问题,我深表歉意,但是在过去一周中,我每天都在论坛,亚马逊的Alexa帮助和Google中进行挖掘,而且我不知道还有什么地方可以转向。 Any help would be super appreciated! 任何帮助将不胜感激!

Ah geeze, I'm a huge friggin' doofus. 哎呀,我真是个大傻瓜。 A friend saw this and asked me to try inputting natural language into the test prompt and it works like a charm now. 一位朋友看到了这一点,并要求我尝试将自然语言输入测试提示,现在它就像一种魅力。 For reference if anyone happens to make this mistake, here's the built-in slot type reference URL: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/slot-type-reference#number 如果有人碰巧犯了此错误,请参考以下内置插槽类型参考URL: https : //developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent- ref / slot-type-reference#number

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM