Alexa Skill Kit(ASK)内在意图“AMAZON.NUMBER”,将数字(“5”)转换为数字(例如“5”)。如何将Alexa AMAZON.NUMBER转换回数字(“5”),以便Alexa能够说出来?
尝试:
"CheckNumberIntent": function (intent, session, response) {
var numberSlot = intent.slots.Number,
numberName;
speech = "Dude you said" + numberSlot + "we should hang out";
var speechOutput = {
speech: speech,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
response.tellWithCard(speechOutput, "Greeter", "Hello World!");
这导致:
"response": {
"outputSpeech": {
"type": "PlainText",
"text": "Dude you said[object Object]we should hang out"
},
答案 0 :(得分:1)
numberSlot
是一个对象,这就是您在输出中看到[object Object]
的原因。 Per the doc您需要引用value
成员。此外,你会想要数字周围的空格,否则你最终会得到
老兄,你说我们应该闲逛
这是更正后的代码:
"CheckNumberIntent": function (intent, session, response) {
var numberSlot = intent.slots.Number,
numberName;
speech = "Dude you said " + numberSlot.value + " we should hang out";
var speechOutput = {
speech: speech,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
response.tellWithCard(speechOutput, "Greeter", "Hello World!");