我是Alexa技能开发新手,从v1到v2迁移时遇到问题。 我的技能是使Alexa记住我使用DynamoDB存储个人物品的位置。基本上就像库存。
我正在使用ask-sdk标准软件包和node js 8.10
我使用.withTableName('PlacesandThings')和.withAutoCreateTable(true)创建表。这是正确的方法吗?我在下面粘贴我的Lambda处理程序
const skillBuilder = Alexa.SkillBuilders.standard();
exports.handler = skillBuilder
.addRequestHandlers(LaunchRequestHandler,
AddThingsIntentHandler,
TellIntentHandler,
HelpIntentHandler,
CancelAndStopIntentHandler,
SessionEndedRequestHandler,
)
.addErrorHandlers(ErrorHandler)
.withTableName('PlacesandThings')
.withAutoCreateTable(true)
.lambda();
我什至无法发动这项技能。我得到的错误如下
{
"errorMessage": "skillBuilder.addRequestHandlers(...).addErrorHandlers(...).withTableName is not a function",
"errorType": "TypeError",
"stackTrace": [
"Module._compile (module.js:652:30)",
"Object.Module._extensions..js (module.js:663:10)",
"Module.load (module.js:565:32)",
"tryModuleLoad (module.js:505:12)",
"Function.Module._load (module.js:497:3)",
"Module.require (module.js:596:17)",
"require (internal/module.js:11:18)"
]
}
我已经配置了两个Intent:AddThingsIntent将值添加到表中,TellIntent则提醒用户项目存储在何处。意向处理程序如下
const AddThingsIntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'AddThingsIntent';
},
handle(handlerInput) {
var ThingName = handlerInput.requestEnvelope.request.intent.slots.ThingName.value;
var PlaceName = handlerInput.requestEnvelope.request.intent.slots.PlaceName.value;
const attributes = handlerInput.attributesManager.getSessionAttributes();
if(attributes.Place === undefined){
attributes.Place = {};
}
attributes.Place[ThingName] = PlaceName;
const speechText = "I will remember that your " + ThingName + "is/are in/on your " +PlaceName;
return handlerInput.responseBuilder
.speak(speechText)
.reprompt(speechText)
.withSimpleCard('Reminder Skill', speechText)
.getResponse();
}
};
const TellIntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'TellIntent';
},
handle(handlerInput) {
var speechText = "";
var ThingName = handlerInput.requestEnvelope.request.intent.slot.ThingName.value;
const attributes = handlerInput.attributesManager.getSessionAttributes();
if(attributes.Place[ThingName]) {
speechText = 'Your' + ThingName + 'is/are in/on ' +attributes.Place[ThingName];
}
else {
speechText = "I don't know where your " +ThingName + "is/are";
}
return handlerInput.responseBuilder
.speak(speechText)
.reprompt(speechText)
.withSimpleCard('Reminder Skill', speechText)
.getResponse();
}
};
我已经在DynamoDB中手动添加了表,并且也尝试过。我应该使用DynamoDB持久性适配器吗?我现在应该怎么办?欢迎任何帮助。