Amazon dynamodb Alexa skill,定制插槽-日期和时间

Amazon dynamodb Alexa skill,定制插槽-日期和时间,amazon-dynamodb,alexa,alexa-skills-kit,alexa-slot,Amazon Dynamodb,Alexa,Alexa Skills Kit,Alexa Slot,我已经创造了一项技能,我希望能够在特定的日期和时间从我的dynamo db表调用机器状态 我的第一列是日期,排序键是时间 我是否需要为一年中所有365天的日期创建一个自定义槽,或者有没有更快的方法来实现这一点?我还需要为一天中的每一分钟创建一个自定义插槽 代码: var AWSregion='us-east-1';//美国东部-1 var AWS=要求('AWS-sdk'); var dbClient=new AWS.DynamoDB.DocumentClient(); AWS.config.

我已经创造了一项技能,我希望能够在特定的日期和时间从我的dynamo db表调用机器状态

我的第一列是日期,排序键是时间

我是否需要为一年中所有365天的日期创建一个自定义槽,或者有没有更快的方法来实现这一点?我还需要为一天中的每一分钟创建一个自定义插槽

代码:

var AWSregion='us-east-1';//美国东部-1
var AWS=要求('AWS-sdk');
var dbClient=new AWS.DynamoDB.DocumentClient();
AWS.config.update({
地区:“'us-east-1'”
});
让GetMachineStateContent=(上下文,回调)=>{
变量参数={
TableName:“updatedincident”,
关键:{
日期:“2018-03-28”,
时间:“04:23”,
}
};
获取(参数,函数(错误,数据){
如果(错误){
//由于某种原因,无法从表中读取。。
console.log('未能加载数据项:\n'+JSON.stringify(err,null,2));
//让skill告诉用户它找不到数据
sendResponse(上下文、回调、{
输出:“无法从数据库加载数据”,
结束会话:false
});
}否则{
log('加载的数据项:\n'+JSON.stringify(data.item,null,2));
//假设该项具有名为“事件”的属性。。
sendResponse(上下文、回调、{
输出:data.Item.incident,
结束会话:false
});
}
});
};
函数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}`
}
};
}
返回响应;
}
exports.handler=(事件、上下文、回调)=>{
试一试{
var request=event.request;
if(request.type==“LaunchRequest”){
sendResponse(上下文、回调、{
输出:“欢迎使用我的技能。您需要什么数据?”,
结束会话:false
});
}
else if(request.type==“IntentRequest”){
让选项={};
if(request.intent.name==“GetMachineStateint”){
getMachineStateint(上下文,回调);
}else if(request.intent.name==“AMAZON.StopIntent”| | request.intent.name==“AMAZON.CancelIntent”){
sendResponse(上下文、回调、{
输出:“好的,再见!”,
结束会话:正确
});
}
else if(request.intent.name==“AMAZON.HelpIntent”){
sendResponse(上下文、回调、{
输出:“您可以询问我已发生的事件”,
责备:“我能帮你什么?”,
结束会话:false
});
}
否则{
sendResponse(上下文、回调、{
输出:“我不知道那个!请再试一次!”,
结束会话:false
});
}
}
else if(request.type==“sessionedrequest”){
sendResponse(上下文,回调,“”;//不需要响应
}
否则{
//收到意外的请求类型..请说我不知道。。
sendResponse(上下文、回调、{
输出:“我不知道那个!请再试一次!”,
结束会话:false
});
}
}捕获(e){
//通过记录错误并发回故障来处理错误
log('技能处理程序中发生意外错误!',e);
如果(回调类型==='undefined'){
失败(“意外错误”);
}否则{
回调(“意外错误”);
}
}
};简短的回答是否定的

在交互模型中,您可以为日期和时间段提供以下内置时间段类型:

  • 内置日期槽:
  • 内置时隙:
文档解释了每种语言对应的话语类型

例如,您可以创建一个交互模型,在其中设置意图,我们称之为
getmachinestatecontent
,然后将以下语句映射到此模型:

what was the machine state at {Time} on {Date}
what was the state of the machine at {Time} on {Date}
what was the machine state at {Time} {Date}
what was the state of the machine at {Time} {Date}
what was the machine state on {Date} at {Time} 
what was the state of the machine on {Date} {Time} 
what was the machine state {Date} at {Time} 
what was the state of the machine {Date} {Time} 
在您的技能中,您将处理
getmachinestatecontent
,并在请求中收到两个插槽中每个插槽的填充值

作为第一步,在构建交互模型时,最好让Alexa简单地用语音回复,确认它从您的请求中收到了日期和时间段值

例如,您可能包括以下内容:

if (request.type === "IntentRequest" && 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
    });
}简而言之,答案是否定的

在交互模型中,您可以为日期和时间段提供以下内置时间段类型:

  • 内置日期槽:
  • 内置时隙:
文档解释了每种语言对应的话语类型

例如,您可以创建一个交互模型,在其中设置意图,我们称之为
getmachinestatecontent
,然后将以下语句映射到此模型:

what was the machine state at {Time} on {Date}
what was the state of the machine at {Time} on {Date}
what was the machine state at {Time} {Date}
what was the state of the machine at {Time} {Date}
what was the machine state on {Date} at {Time} 
what was the state of the machine on {Date} {Time} 
what was the machine state {Date} at {Time} 
what was the state of the machine {Date} {Time} 
在您的技能中,您将处理
getmachinestatecontent
,并在请求中收到两个插槽中每个插槽的填充值

作为第一步,在构建交互模型时,最好让Alexa简单地用语音回复,确认它从您的请求中收到了日期和时间段值

例如,您可能包括以下内容:

if (request.type === "IntentRequest" && 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
    });

}

谢谢,我的约会是以什么形式进行的,这有关系吗?因为atm我有天/月/年,而我的技能似乎不起作用。这是当前的错误。我收到了技能处理程序中发生的意外错误!TypeError:无法读取属性“ty”