Amazon dynamodb alexa skill local无法给dynamodb写信

Amazon dynamodb alexa skill local无法给dynamodb写信,amazon-dynamodb,alexa-skills-kit,Amazon Dynamodb,Alexa Skills Kit,我正在使用ask sdk编写node.js skill,并使用alexa skill local测试端点。我需要将数据持久化到其中一个处理程序中的DynamoDb。但我不断得到“缺失区域错误”。请在下面找到我的代码: 'use strict'; // use 'ask-sdk' if standard SDK module is installed const Alexa = require('ask-sdk'); const { launchRequestHandler, HelpInte

我正在使用ask sdk编写node.js skill,并使用alexa skill local测试端点。我需要将数据持久化到其中一个处理程序中的DynamoDb。但我不断得到“缺失区域错误”。请在下面找到我的代码:

'use strict';

// use 'ask-sdk' if standard SDK module is installed
const Alexa = require('ask-sdk');

const { launchRequestHandler, HelpIntentHandler, CancelAndStopIntentHandler, SessionEndedRequestHandler } = require('./commonHandlers');

const ErrorHandler = {
    canHandle() {
        return true;
    },
    handle(handlerInput, error) {
        return handlerInput.responseBuilder
            .speak('Sorry, I can\'t understand the command. Please say again.')
            .reprompt('Sorry, I can\'t understand the command. Please say again.')
            .getResponse();
    },
};

////////////////////////////////
// Code for the handlers here //
////////////////////////////////
exports.handler = Alexa.SkillBuilders
    .standard()
    .addRequestHandlers(
        launchRequestHandler,
        HelpIntentHandler,
        CancelAndStopIntentHandler,
        SessionEndedRequestHandler,
        ErrorHandler
    )
    .withTableName('devtable')
    .withDynamoDbClient()
    .lambda();
在其中一个处理程序中,我尝试获取以下持久化属性:

handlerInput.attributesManager.getPersistentAttributes().then((data) => {
    console.log('--- the attributes are ----', data)
})
但我一直得到以下错误:

(node:12528) UnhandledPromiseRejectionWarning: AskSdk.DynamoDbPersistenceAdapter Error: Could not read item (amzn1.ask.account.AHJECJ7DTOPSTT25R36BZKKET4TKTCGZ7HJWEJEBWTX6YYTLG5SJVLZH5QH257NFKHXLIG7KREDKWO4D4N36IT6GUHT3PNJ4QPOUE4FHT2OYNXHO6Z77FUGHH3EVAH3I2KG6OAFLV2HSO3VMDQTKNX4OVWBWUGJ7NP3F6JHRLWKF2F6BTWND7GSF7OVQM25YBH5H723VO123ABC) from table (EucerinSkinCareDev): Missing region in config
    at Object.createAskSdkError (E:\projects\nodejs-alexa-sdk-v2-eucerin-skincare-dev\node_modules\ask-sdk-dynamodb-persistence-adapter\dist\utils\AskSdkUtils.js:22:17)
    at DynamoDbPersistenceAdapter.<anonymous> (E:\projects\nodejs-alexa-sdk-v2-eucerin-skincare-dev\node_modules\ask-sdk-dynamodb-persistence-adapter\dist\attributes\persistence\DynamoDbPersistenceAdapter.js:121:45)
(节点:12528)未处理的Promiser弹出警告:AskSdk.dynamodbpersistenceheadapter错误:无法读取项(amzn1.ask.account.ahjecj7dtopt25r36bzkket4tcgz7hjwejebwtx6yytlg5sjlzh5qh257nfkhxlig7kredkwo4n36it6guht3pj4pqpoue4fht2oynxh6v77fughh3evah3k2kg6oafl2hso3vmdk4nxwwwwwwwwwwwwwwww7npg7wk7f7vqh5v3f7vqh5v3f3f7v3f3f7v3f3f3f3f3f3f3f3f3f3来自表(EUCERINSKINCEREDEV):配置中缺少区域
在Object.createAskSdkError(E:\projects\nodejs-alexa-sdk-v2-eucerin-skincare-dev\node\u modules\ask sdk dynamodb持久性适配器\dist\utils\AskSdkUtils.js:22:17)
在DYNAMODBPERSISTEADAPTER。(E:\projects\nodejs-alexa-sdk-v2-eucerin-skincare-dev\node\u modules\ask sdk dynamodb persistence adapter\dist\attributes\persistence\dynamodbpersistenceeadapter.js:121:45)
我们可以使用alexa skill local从DynamoDb读取和写入属性吗?我们需要一些不同的设置来实现这一点吗


谢谢

假设您有一个AWS配置文件,您的技能在本地运行时使用该配置文件

您需要编辑.config文件并在那里设置默认区域(即us-east-1)。区域应与表所在的区域匹配


或者,如果您希望能够完全独立地运行,您可能需要编写come条件逻辑,并将dynamo客户端与在您的机器上运行的DynamoDB Local实例进行交换。

我知道这是一个非常古老的主题,但几天前我遇到了同样的问题,我将解释我是如何工作的。 您必须在本地下载DynamoDB,并按照

一旦您配置了本地DynamoDB并检查它是否正常工作。您必须通过代码将其传递给dynamodbpersistencedapter构造函数。 您的代码应类似于:

var awsSdk = require('aws-sdk');
var myDynamoDB = new awsSdk.DynamoDB({
    endpoint: 'http://localhost:8000', // If you change the default url, change it here
    accessKeyId: <your-access-key-id>,
    secretAccessKey: <your-secret-access-key>,
    region: <your-region>,
    apiVersion: 'latest'
});

const {DynamoDbPersistenceAdapter} = require('ask-sdk-dynamodb-persistence-adapter');
return new DynamoDbPersistenceAdapter({
    tableName: tableName || 'my-table-name',
    createTable: true,
    dynamoDBClient: myDynamoDB
});
var awsSdk=require('aws-sdk');
var myDynamoDB=新的awsSdk.DynamoDB({
端点:'http://localhost:8000“,//如果更改默认url,请在此处更改
accessKeyId:,
secretAccessKey:,
地区:,
apiVersion:'最新'
});
const{dynamodbpersistencedapter}=require('ask-sdk-dynamodb-persistence-adapter');
返回新的DynamoDbPersistenceAdapter({
tableName:tableName | |“我的表名”,
createTable:true,
DynamodB客户:myDynamoDB
});
其中,
在aws配置和凭证文件中定义


下一步是一如既往地使用
alexa skill local
命令启动服务器


希望这会有帮助!=)

alexa skill local
的目的是创建本地开发服务器并在alexa开发控制台中更新端点。您在这里提到的问题与@Mike在下面的回答中提到的不提供AWS配置文件有关,而与
alexa skill local
无关。免责声明:我是
alexa skill local
的创建者。