我正在努力构建一个Alexa技能,并且在将我的插槽值从intent对象中取出时遇到了障碍 . 意图对象JSON如下所示:
"intent": {
"name": "string",
"slots": {
"string": {
"name": "string",
"value": "string"
}
}
}
我的问题是,第一个“字符串”值将用于识别插槽?文档包含:
A map of key-value pairs that further describes what the user meant based on a predefined intent schema. The map can be empty.
The key is a string that describes the name of the slot. Type: string.
The value is an object of type slot. Type: object. See Slot Object.
这是否意味着获取插槽的关键是我在交互模型中设置的名称?我犹豫不决的唯一原因是因为我们已经在插槽中有一个名称对象,这绝对是插槽的名称 - 所以如果通过名称访问特定插槽的方式,名称参数将多余(您已经知道访问插槽的名称 . )
有谁知道如何访问Alexa技能中的各个槽值?
顺便说一句,我正在使用NodeJS来获得这项技能 .
3 回答
让我们假设我们在交互模型中有一个名称创建 Session 请求的意图 .
而你想用lambda代码访问它 . 您可以使用以下行 .
this
是Object包含来自alexa的完整JSON请求 . 所以你可以使用slotname访问任何插槽例如:如果我们想访问subject slot
那么我们可以使用this.event.request.intent.slots.subject.value
由于我遇到了很多麻烦,一个更具体的答案(现在)是:
使用此意图架构:
这是您的结构意图的示例:
因此,这意味着您使用的Intent被命名为:Movie Intent(您在交互模型中设置的那个) . 你将以这种方式获得 Value :