0

在 node.js 中开发的 Alexa 技能不会在 Alexa 应用程序的主页中显示任何卡片,对于带有 npm 包 'alexa-sdk' 的 Simple 或 Standard Card 类型。'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);
  }
4

1 回答 1

0

对于带有图像的标准 Alexa 卡,您必须包含具有smallImageUrllargeImageUrl属性的图像对象。smallImageUrl并且largeImageUrl是要显示的图像的小版本和大版本的 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"
      }
    }
...

使用同时具有smallImageUrl和的图像对象更新您的代码largeImageUrl

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);

更多关于标准卡的信息在这里

卡片图像必须满足某些条件,例如:

  1. 图像格式和大小
  2. 托管图像
于 2018-10-04T13:09:44.900 回答