node.js 开发的 Alexa 技能不显示任何卡片

Alexa skill developed in node.js doesn't display any card

在 node.js 中开发的 Alexa 技能不会在 Alexa 应用程序的主页中显示任何卡片,对于带有 npm 包 'alexa-sdk' 的简单或标准卡片类型。 'Alexa-sdk' 包的 response.js 文件似乎有问题。 我用了下面的方法

'THREE_D_QuestionIntent': function() {

    let reply = " Here’s a list"
    let speechOutput = reply;
    let repromptSpeech = "Question";
    let cardTitle = resultCardTitle;
    let cardContent = "Result is ";
    let imageObj = "https://s3.amazonaws.com/visitmadison/HTML/shape.png";

    console.log(speechOutput);

    this.emit(':askWithCard', speechOutput, repromptSpeech, cardTitle, cardContent, imageObj);
  }

对于带有图像的标准 Alexa 卡片,您已包含一个具有 smallImageUrllargeImageUrl 属性的图像对象。 smallImageUrllargeImageUrl 是要显示的图像的小版本和大版本的 URL。

例如,响应 JSON 将具有:

...
"card": {
      "type": "Standard",
      "title": "Ordering a Car",
      "text": "Your ride is on the way",
      "image": {
        "smallImageUrl": "https://carfu.com/resources/card-images/race-car-small.png",
        "largeImageUrl": "https://carfu.com/resources/card-images/race-car-large.png"
      }
    }
...

使用同时具有 smallImageUrllargeImageUrl

的图像对象更新您的代码
var speechOutput = 'your speech here';
var repromptSpeech = 'your re prompt here';
var cardTitle = 'card title here';
var cardContent = 'card content here';
var imageObj = {
   "smallImageUrl": "https://carfu.com/resources/card-images/race-car-small.png",
   "largeImageUrl": "https://carfu.com/resources/card-images/race-car-large.png"
};
this.emit(':askWithCard', speechOutput, repromptSpeech, cardTitle, cardContent, imageObj);

关于标准卡的更多信息here

名片图片必须满足特定条件,例如:

  1. Image Format and Size
  2. Hosting the Images