我已經建立斷例子標準卡在alexa-skills-kit-js/samples/Alexa的技能套件:如何將圖片添加到使用JS
但如果你添加一個圖像到響應卡,他們就沒有任何。
response.askWithCard(speechOutput, repromptOutput, cardTitle, cardContent);
哪裏像去了? cardContent通常是一個字符串。我只是把它變成一個包含圖像的物體......?
我已經建立斷例子標準卡在alexa-skills-kit-js/samples/Alexa的技能套件:如何將圖片添加到使用JS
但如果你添加一個圖像到響應卡,他們就沒有任何。
response.askWithCard(speechOutput, repromptOutput, cardTitle, cardContent);
哪裏像去了? cardContent通常是一個字符串。我只是把它變成一個包含圖像的物體......?
不幸的是,它看起來像'簡單'是硬編碼的,'小'和大圖像URL需要'標準'卡片。下面是從
https://github.com/amzn/alexa-skills-kit-js/blob/master/samples/historyBuff/src/AlexaSkill.js#L142
if (options.cardTitle && options.cardContent) {
alexaResponse.card = {
type: "Simple",
title: options.cardTitle,
content: options.cardContent
};
}
的代碼,你需要修改你的本地AlexaSkill.js副本添加的功能。
這裏是API的使用瓶-ASK庫(礦)顯示卡的工作原理:
https://johnwheeler.org/flask-ask/responses.html#displaying-cards-in-the-alexa-smartphone-tablet-app
我也跟着reply對馬克斯金格亞馬遜開發者支持論壇類似的問題:
我一直在努力與此自己,現在有它的工作。如果 您使用亞馬遜提供的示例AlexaSkill.js模塊,然後 您需要添加幾個部分來處理圖片卡。
if (options.cardSmallImageURL && options.cardLargeImageURL) { alexaResponse.card = { type: "Standard", title: options.cardTitle, text: options.cardContent, image: { smallImageUrl: options.cardSmallImageURL, largeImageUrl: options.cardLargeImageURL } }; }
再經過askWithCard定義再往下補充一點::
在buildSpeechletResponse部分相似類型後 「簡單」中添加該
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 正在使用測試;
response.askWithPictureCard(「這是語音輸出」,「這是 重新提示」,「這是卡標題」,「這是卡文,注意 場被稱爲文本不cardContent」, 'https://s3.amazonaws.com/thisisthesmallpictureurl-small.jpg', 'https://s3.amazonaws.com/thisisthebigpictureurl-big.jpg');
然後按照類似的過程添加tellWithPictureCard函數。
有代碼那裏有斯金格把CRD時,他的意思卡我糾正了我上面貼一個小錯字。除此之外,這種方法爲我工作。