从意图中获取Alexa广告位值 [英] Getting an Alexa Slot value out of an intent

查看:98
本文介绍了从意图中获取Alexa广告位值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力培养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.

这是否意味着获得广告位的关键是我在交互模型中设置的名称?我犹豫的唯一原因是因为我们已经在插槽中有了一个名称对象,这绝对是插槽的名称-因此,如果访问特定插槽的方式是通过名称,则name参数将是多余的(您已经从访问插槽中知道了名称。)

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广告位值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆