我自己一直在努力解决这个问题,现在它可以工作了。如果
您正在使用亚马逊提供的示例 AlexaSkill.js 模块
你需要添加几个部分来处理图片卡。
在 buildSpeechletResponse 部分中,在类似类型之后添加
“简单”部分:
if (options.cardSmallImageURL && options.cardLargeImageURL) {
alexaResponse.card = {
type: "Standard",
title: options.cardTitle,
text: options.cardContent,
image: {
smallImageUrl: options.cardSmallImageURL,
largeImageUrl: options.cardLargeImageURL
}
};
}
然后在 askWithCard 定义之后再往下添加:
askWithPictureCard: function(speechOutput, repromptSpeech, cardTitle, cardContent, smallImageURL, largeImageURL) {
this._context.succeed(buildSpeechletResponse({
session: this._session,
output: speechOutput,
reprompt: repromptSpeech,
cardTitle: cardTitle,
cardContent: cardContent,
cardSmallImageURL: smallImageURL,
cardLargeImageURL: largeImageURL,
shouldEndSession: false
}));
现在你可以调用它了,可能使用变量而不是常量 I
正在使用 using 进行测试;
response.askWithPictureCard('这是语音输出', '这是
reprompt', '这是卡片标题', '这是卡片文字,注意
字段称为文本而不是 cardContent',
'https://s3.amazonaws.com/thisisthesmallpictureurl-small.jpg',
'https://s3.amazonaws.com/thisisthebigpictureurl-big.jpg');
然后按照类似的过程添加一个tellWithPictureCard函数。