Aws lambda ASK错误,TypeError:无法读取属性';类型';未定义的

Aws lambda ASK错误,TypeError:无法读取属性';类型';未定义的,aws-lambda,amazon-dynamodb,alexa,alexa-skills-kit,Aws Lambda,Amazon Dynamodb,Alexa,Alexa Skills Kit,我正在创造一种技能,通过Alexa从DynamoDB表格中调用不同日期和时间的不同事件 我的3列是数据、时间和事件 我在Lambda函数中将分区和排序键定义为 让getMachineStateContent=(上下文,回调)=>{ 变量参数={ TableName:“updatedincident”, 关键:{ 日期:“2017-03-21”, 时间:“07:38”, 事件:“阻止主要”, } };由于您尚未共享index.js文件中的代码,因此无法确定这是否是问题所在。您收到的错误消息告诉您

我正在创造一种技能,通过Alexa从DynamoDB表格中调用不同日期和时间的不同事件

我的3列是数据、时间和事件

我在Lambda函数中将分区和排序键定义为

让getMachineStateContent=(上下文,回调)=>{
变量参数={
TableName:“updatedincident”,
关键:{
日期:“2017-03-21”,
时间:“07:38”,
事件:“阻止主要”,
}

};
由于您尚未共享index.js文件中的代码,因此无法确定这是否是问题所在。您收到的错误消息告诉您,问题发生在index.js文件的第70行,因此您应该查看该行,并找出问题所在

然而,基于您也将此作为评论发布的事实,我冒昧地猜测,您遇到的问题是您使用了我在中提供的代码段,错误是由于取消引用了
请求。键入

您必须确保将请求变量设置为来自事件的实际请求,如下所示:
var request=event.request
其中事件是从
exports.handler=(事件、上下文、回调)=>{

例如:

exports.handler = (event, context, callback) => {
  var request = event.request;
  if (request.type === "IntentRequest" 
      // make suret the name of the intent matches the one in your interaction model
   && request.intent.name == "GetMachineStateIntent") {
    var dateSlot = request.intent.slots.Date != null ?
                   request.intent.slots.Date.value : "unknown date";
    var timeSlot = request.intent.slots.Time != null ?
                   request.intent.slots.Time.value : "unknown time";

    // respond with speech saying back what the skill thinks the user requested
    sendResponse(context, callback, {
       output: "You wanted the machine state at " 
              + timeSlot + " on " + dateSlot,
       endSession: true
    });
  } else {
    // TODO:  handle other types of requests..
    sendResponse(context, callback, {
       output: "I don't know how to handle this request yet!"
       endSession: true
    }); 
  } 
};

function sendResponse(context, callback, responseOptions) {
  if(typeof callback === 'undefined') {
    context.succeed(buildResponse(responseOptions));
  } else {
    callback(null, buildResponse(responseOptions));
  }
}

function buildResponse(options) {
  var alexaResponse = {
    version: "1.0",
    response: {
      outputSpeech: {
        "type": "SSML",
        "ssml": `<speak><prosody rate="slow">${options.output}</prosody></speak>`
      },
      shouldEndSession: options.endSession
    }
  };
  if (options.repromptText) {
    alexaResponse.response.reprompt = {
      outputSpeech: {
        "type": "SSML",
        "ssml": `<speak><prosody rate="slow">${options.reprompt}</prosody></speak>`
      }
    };
  }
  return alexaResponse;
} 
exports.handler=(事件、上下文、回调)=>{
var request=event.request;
if(request.type==“IntentRequest”
//确保意图的名称与交互模型中的名称匹配
&&request.intent.name==“GetMachineStateint”){
var dateSlot=request.intent.slots.Date!=null?
request.intent.slots.Date.value:“未知日期”;
var timeSlot=request.intent.slots.Time!=null?
request.intent.slots.Time.value:“未知时间”;
//用言语回应,说出技能认为用户要求的内容
sendResponse(上下文、回调、{
输出:“您希望机器状态处于”
+时隙+“on”+日期槽,
结束会话:正确
});
}否则{
//TODO:处理其他类型的请求。。
sendResponse(上下文、回调、{
输出:“我还不知道如何处理这个请求!”
结束会话:正确
}); 
} 
};
函数sendResponse(上下文、回调、响应选项){
如果(回调类型==='undefined'){
success(buildResponse(responseOptions));
}否则{
回调(null,buildResponse(responseOptions));
}
}
函数buildResponse(选项){
变量响应={
版本:“1.0”,
答复:{
输出语音:{
“类型”:“SSML”,
“ssml”:“${options.output}`
},
shouldEndSession:options.endSession
}
};
如果(选项.重新打印文本){
alexaResponse.response.reprompt={
输出语音:{
“类型”:“SSML”,
“ssml”:“${options.reprompt}`
}
};
}
返回响应;
} 

Hi mike,我已经在这个问题上添加了我的index.js和我的处理程序,伙计,我真的希望你有一个最好的复活节!那么为什么你有两个文件?index.js和GetMachineState.js?第二个用于什么?你是如何测试技能的?使用Alexa,或者其他方式?GetMachineState.js是我相信的处理程序,我正在测试usi在alexa开发者控制台上,很抱歉回复太晚了。这取决于您希望它如何工作。您可以修改回复以给出机器状态,而不是重复/确认问题。或者,如果您保留确认,您可以将AMAZON.YesInt添加到您的交互模型中,并以您的技能处理它以返回答案。对于后者,您还必须打开麦克风来记录用户的响应,这可以通过将到目前为止的响应中的shouldEndSession设置为false来完成。您还必须将查询参数存储在skill session属性中。总的来说有点复杂。是的,当然。And就像我说的,保持查询的最简单方法可能是使用会话属性。看看这篇博文。它讨论了在类似任务中使用会话属性: