我已经创建了一项技能,我希望能够在某个日期和时间从我的发电机数据库表中调用机器状态。
我的第一列是日期,我的排序键是时间。
我是否需要为一年中所有365天创建一个自定义插槽日期,或者是否有更快的方法来执行此操作?我还需要为一天中的每一分钟创建一个自定义插槽。
代码:
//Here is how you can get List of Element from List<ElementGroup>.
List<Element> result =
elements.SelectMany(elementGroup =>
elementGroup.Where(element=>element.Name=="Wires")).ToList();
&#13;
答案 0 :(得分:2)
简短回答是否
在您的交互模型中,您可以为日期和时间段提供以下内置插槽类型:
文档解释了每种话语的映射类型。
例如,您可以创建一个交互模型,在其中设置一个intent,让我们将其称为GetMachineStateIntent
,然后将以下话语映射到此模型:
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}
在您的技能中,您将处理GetMachineStateIntent
,并且在请求中您将收到两个插槽中每个插槽的填充值。
作为第一步,在构建交互模型时,让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
});
}