Alexa Skill S3 在参数中缺少必需的密钥桶

如何解决Alexa Skill S3 在参数中缺少必需的密钥桶

我正在尝试根据 Cake Time Tutorial 创建一项技能,但是每当我尝试调用我的技能时,我都会遇到一个我不知道为什么的错误

这是我的调用函数

    const LaunchRequestHandler = {
       canHandle(handlerInput) {
         console.log(`Can Handle Launch Request ${(Alexa.getRequestType(handlerInput.requestEnvelope) === "LaunchRequest")}`);
         return (
           Alexa.getRequestType(handlerInput.requestEnvelope) === "LaunchRequest"
         );
       },handle(handlerInput) {
         const speakOutput =
           "Bem vindo,que série vai assistir hoje?";
           console.log("handling launch request");
           console.log(speakOutput);
         return handlerInput.responseBuilder
           .speak(speakOutput)
           .reprompt(speakOutput)
           .getResponse();
       },};

它应该只提示一条葡萄牙语的消息“Bem vindo,que série vaiassisir hoje?”但它出于某种原因尝试访问 amazon S3 存储桶并在控制台上打印此错误

~~~~ Error handled: AskSdk.S3PersistenceAdapter Error: Could not read item (amzn1.ask.account.NUMBEROFACCOUNT) from bucket (undefined): Missing required key 'Bucket' in params
    at Object.createAskSdkError (path\marcaEpisodio\lambda\node_modules\ask-sdk-s3-persistence-adapter\dist\utils\AskSdkUtils.js:22:17)
    at S3PersistenceAdapter.<anonymous> (path\marcaEpisodio\lambda\node_modules\ask-sdk-s3-persistence-adapter\dist\attributes\persistence\S3PersistenceAdapter.js:90:45)
    at step (path\marcaEpisodio\lambda\node_modules\ask-sdk-s3-persistence-adapter\dist\attributes\persistence\S3PersistenceAdapter.js:44:23)
    at Object.throw (path\marcaEpisodio\lambda\node_modules\ask-sdk-s3-persistence-adapter\dist\attributes\persistence\S3PersistenceAdapter.js:25:53)
    at rejected (path\marcaEpisodio\lambda\node_modules\ask-sdk-s3-persistence-adapter\dist\attributes\persistence\S3PersistenceAdapter.js:17:65)
    at processticksAndRejections (internal/process/task_queues.js:93:5)
Skill response
 {
  "type": "SkillResponseSuccessMessage","originalRequestId": "wsds-transport-requestId.v1.IDREQUESTED","version": "1.0","responsePayload": "{\"version\":\"1.0\",\"response\":{\"outputSpeech\":{\"type\":\"SSML\",\"ssml\":\"<speak>Desculpe,não consegui fazer o que pediu.</speak>\"},\"reprompt\":{\"outputSpeech\":{\"type\":\"SSML\",não consegui fazer o que pediu.</speak>\"}},\"shouldEndSession\":false},\"userAgent\":\"ask-node/2.10.2 Node/v14.16.0\",\"sessionAttributes\":{}}"
}
----------------------

我从堆栈错误删除了一些 ID 信息,但我认为它们与目的无关。

我能想到的唯一调用是当我在 alexa Skill Builder 中添加 S3 适配器时。

exports.handler = Alexa.SkillBuilders.custom()
  .withapiclient(new Alexa.Defaultapiclient())
  .withPersistenceAdapter(
    new persistenceAdapter.S3PersistenceAdapter({
      bucketName: process.env.S3_PERSISTENCE_BUCKET,})
  )
  .addRequestHandlers(
    LaunchRequestHandler,marcaEpisodioIntentHandler,HelpIntentHandler,CancelAndStopIntentHandler,SessionEndedRequestHandler,IntentReflectorHandler // make sure IntentReflectorHandler is last so it doesn't override your custom intent handlers
  )
  .addRequestInterceptors(marcaEpisodioInterceptor)
  .addErrorHandlers(ErrorHandler)
  .lambda();

这些是我创建的 Intent Intents

这是应该处理它们的函数

const Alexa = require("ask-sdk-core");
const persistenceAdapter = require("ask-sdk-s3-persistence-adapter");

const intentName = "marcaEpisodioIntent";

const marcaEpisodioIntentHandler = {
  canHandle(handlerInput) {
    console.log("Trying to handle wiht marca episodio intent");
    return (
      Alexa.getRequestType(handlerInput.requestEnvelope) !== "LaunchRequest" &&
      Alexa.getRequestType(handlerInput.requestEnvelope) === "IntentRequest" &&
      Alexa.getIntentName(handlerInput.requestEnvelope) === intentName
    );
  },async chandle(handlerInput) {
    const serie = handlerInput.requestEnvelope.request.intent.slots.serie.value;
    const episodio =
      handlerInput.requestEnvelope.request.intent.slots.episodio.value;
    const temporada =
      handlerInput.requestEnvelope.request.intent.slots.temporada.value;
    const attributesManager = handlerInput.attributesManager;
    const serieMark = {
      serie: serie,episodio: episodio,temporada: temporada,};
    attributesManager.setPersistentAttributes(serieMark);
    await attributesManager.savePersistentAttributes();

    const speakOutput = `${serie} marcada no episódio ${episodio} da temporada ${temporada}`;

    return handlerInput.responseBuilder.speak(speakOutput).getResponse();
  },};

module.exports = marcaEpisodioIntentHandler;

任何帮助将不胜感激。

解决方法

相反,它出于某种原因尝试访问 amazon S3 存储桶

首先,在轮询意图处理程序的 canHandle 函数之前,每次使用时都会加载和配置持久性适配器。然后在轮询它们中的任何一个之前,在 RequestInterceptor使用持久性适配器。

如果那里有问题,它会在您到达 LaunchRequestHandler 之前中断,这就是正在发生的事情。

其次,您是在 Alexa 开发者控制台中构建 Alexa 托管的技能还是通过 AWS 托管自己的 Lambda?

Alexa 托管会为您创建大量资源,包括 Amazon S3 存储桶和 Amazon DynamoDb 表,然后确保它为您创建的 AWS Lambda 具有必要的角色设置和其环境变量中的正确信息。

>

如果您通过 AWS 托管自己的,您的 Lambda 将需要一个对您的 S3 资源具有读/写权限的角色,并且您需要将存储持久值的存储桶设置为您的环境变量Lambda(或将 process.env.S3_PERSISTENCE_BUCKET 替换为包含存储桶名称的字符串)。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?