从意图中获取 Alexa Slot 值 [英] Getting an Alexa Slot value out of an intent
问题描述
我正在努力构建 Alexa 技能,但在从意图对象中获取我的槽值时遇到了障碍.意图对象 JSON 如下所示:
I'm working to build an Alexa skill and have run into a roadblock on getting my slot values out of the intent object. The intent object JSON looks like so:
"intent": {
"name": "string",
"slots": {
"string": {
"name": "string",
"value": "string"
}
}
}
我的问题是第一个字符串"值是什么来标识插槽?文档有这个:
My question is what will that first "string" value be to identify the slots? The documentation has this:
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.
这是否意味着获得插槽的关键是我在交互模型中设置的名称?我犹豫不决的唯一原因是因为我们已经在插槽中有一个名称对象,这绝对是插槽的名称——所以如果访问特定插槽的方式是通过名称,则名称参数将是多余的(您已经通过访问插槽知道名称.)
Does this mean the key to get the slot is the name I set in the Interaction Model? The only reason I'm hesitant to think that is because we already have a name object in the slot, which is definitely the name of the slot -- so if the way to access a specific slot was via the name, the name parameter would be redundant (you already know the name from accessing the slot.)
有谁知道我如何访问 Alexa 技能中的各个槽值?
Does anyone know how I go about accessing individual slot values in an Alexa skill?
顺便说一下,我正在使用 NodeJS 来完成这项技能.
I'm using NodeJS for this skill by the way.
推荐答案
由于我在这方面遇到了很多麻烦,更具体的答案(现在)是:
Since I had a lot of trouble with this, a more concrete answer (now) is:
'PersonIntent': function () {
var text = 'Hello ' + this.event.request.intent.slots.FirstPerson.value;
this.emit(':tell', text);
},
有了这个意图架构:
{
"intents": [
{
"intent": "PersonIntent",
"slots": [
{
"name": "FirstPerson",
"type": "AMAZON.DE_FIRST_NAME"
}
]
}
]
}
这篇关于从意图中获取 Alexa Slot 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!