将Alexa AMAZON.NUMBER转换回数字(“five”),以便Alexa能够说出来

时间:2016-03-16 08:22:31

标签: node.js alexa-skills-kit

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"
    },

1 个答案:

答案 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!");