Alexa - 如何向用户发送图像?

Alexa - How to send image to user?

我正在为我的 Alexa Skill 使用 Lambda 函数。对于我的启动意图,我查询 DynamoDB 和 return 一个字符串,我首先想将其转换为 QRCode,然后我想 return 它作为 responseBuilder 中的图像发送到 Alexa 设备

Alexa 可以很好地显示来自外部 url 的图像,例如

const rabbitImage = "https://i.imgur.com/U6eF0oH.jpeg";

return responseBuilder
        .speak(say)
        .withStandardCard("Welcome to Alexa", "description", rabbitImage, rabbitImage)
        .reprompt('try again, ' + say)
        .getResponse();

但我一直在研究如何将 QRCode 发送回 responseBuilder 中的 Alexa 设备。

我正在使用一个名为 qrcodenodejs 库,它可以将字符串转换为 QRCode,然后转换为 base64

https://www.npmjs.com/package/qrcode

但根据发送 "card" aka image 的 Alexa 文档,返回给用户的必须是 url.

https://developer.amazon.com/en-US/docs/alexa/custom-skills/include-a-card-in-your-skills-response.html

The Alexa Skills Kit provides different types of cards:

A Standard card also displays plain text, but can include an image. You provide the text for the title and content, and the URL for the image to display.

所以我不确定 qrcode 库生成的 base64 是否适用于这种情况。

在这种情况下,将动态生成的 QRCode 作为响应发送回 Alexa 设备的最佳方式是什么?

const LaunchRequest_Handler = {
    canHandle(handlerInput) {
      const request = handlerInput.requestEnvelope.request;
      return request.type === 'LaunchRequest';
    },
    handle(handlerInput) {
      const responseBuilder = handlerInput.responseBuilder;


      //Perform query to DynamoDB

      var stringToCreateQRWith = "8306e21d-0c9e-4465-91e9-0cf86fca110d";

      //Generate qr code and send back to user here
      //???Unsure how to do and what format to send it in
      var qrImageToSendToUser = ???

      return responseBuilder
        .speak(say)
        .withStandardCard("Welcome to Alexa", "description", qrImageToSendToUser , qrImageToSendToUser )
        .reprompt('try again, ' + say)
        .getResponse();

    }

正如@kopaka 所建议的那样,这是要走的路。 没办法了。

根据the documentation

它们是您需要牢记的几件事。

在图像本身上,您需要使用 720px x 480px1200px x 800px 创建 2 个图像。确保它们在多种屏幕尺寸上都能很好地显示。否则他们无法保证为您的用户提供最佳体验,因为他们可能会缩放 up/down 图像以适合。

关于存储选择,您需要确保能够通过 Https 提供这些图像,并使用受 amazon 信任的有效 ssl 证书。