我正在开发一个带有一个Intent的Alexa技能,其中包含一个带有几个可能值的Slot .
我的插槽定义为 "name" : "Channel"
, "type" : "LIST_OF_CHANNELS"
和值
-
iqram
-
ingrid
-
phil
-
克莱德
如何检索在我的Lambda函数中使用的发音 slot value ?这是"retrieve value of slot from utterance part"我希望得到回答 . 非常感谢 .
// retrieve value of slot from utterance
var c = intent.slots.Channel.value;
// append value to end of URL that references API
fetchEnseParse("/channel/" + c, function(body) {
// continuation of this function is below
6 回答
var c = this.event.request.intent.slots.slotname.value
这应该会给你你想要的东西 .
如果你的lambda收到你可以在这里找到它...
该事件将传递给您的lambda处理程序 .
对我来说,以下工作:
其中
slot-name
是Channel
.简单地看
this.event.request.intent.slots.<yourslot>.value
是不安全的这个值只有'话语',可能不是你想要的
我不得不深入到对象并查看resolution对象并检查状态为
code=="ER_SUCCESS_MATCH"
的权限对象这是我的java代码 - 你可以在Nodejs中做同样的事情
让我们说你对alexa说“ coin ”这个词,你把它编程为 bitcoin (主要对象名)的同义词 .
现在你可以获得2个结果 .
第一:你得到原始值“比特币”,这是原始值/匹配值
或者第二:你得到口语 Value “硬币”
First (bitcoin):
Second (coin):
小心:yourslotname不是Slottype!这是名字