DIR*_*AVE 8 amazon-web-services node.js aws-lambda alexa-skills-kit
我正在为我的 Alexa Skill 使用 Lambda 函数。对于我的启动意图,我查询 DynamoDB 并返回一个字符串,我首先想要将其转换为 QRCode,然后我想将其作为图像内的图像返回到 Alexa 设备。responseBuilder
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();
Run Code Online (Sandbox Code Playgroud)
但我陷入了如何将 QRCode 发送回 Alexa 设备的问题responseBuilder。
我正在使用一个nodejs名为 的库qrcode,它可以将字符串转换为 QRCode,然后转换为base64.
https://www.npmjs.com/package/qrcode
但根据 Alexa 文档,"card" aka image向用户发送 , 时它必须是一个 url。
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.
Run Code Online (Sandbox Code Playgroud)
所以我不确定库base64生成的qrcode在这种情况下是否有效。
在这种情况下,将动态生成的 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();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
406 次 |
| 最近记录: |