繁体   English   中英

完全匹配样本话语的Alexa无法通过插槽值

[英]Alexa exactly matching sample utterance fails to pass slot value through

我具有名为“ rollDice”的意图的Alexa技能。 该意图有两种说法:

roll a {sides} sided dice
roll a {sides} sided die

sides与槽型下面定义AMAZON.NUMBER

该技能成功构建,我打开它并运行“掷出20个双面骰子”,它运行正确的意图请求处理程序,但是当我尝试使用sides slot的值时,它是undefined 我检查了JSON Input面板,发现没有通过:

"intent": {
    "name": "rollDice",
    "confirmationStatus": "NONE",
    "slots": {
        "sides": {
            "name": "sides",
            "confirmationStatus": "NONE"
        }
    }
}

这是我处理rollDice意图的代码:

module.exports = ({ store, slot }) => {
  const sideCount = +slot('sides', 6);
  const roll = 1 + Math.floor(Math.random() * sideCount);
  store.state.rolls.push({sideCount, roll});
  return `Rolled a ${sideCount} sided dice and got ${roll}. ${slot('sides')}`;
};

我从Alexa得到的回应是:

Rolled a 6 sided dice and got 4. undefined

我在其他几个Intent处理程序中使用了slot函数,没有问题,所以我不认为这是问题,但在这种情况下,以防万一:

slot(name, defaultValue) {
  const { intent } = this;
  const slot = intent && intent.slots && intent.slots[name];
  return slot && slot.value || defaultValue;
}

编辑:

这是我的Lambda函数中的event.request.intent的值,在roll a 20 sided dice后运行:

{
  "name": "rollDice",
  "confirmationStatus": "NONE",
  "slots": {
    "sides": {
      "name": "sides",
      "confirmationStatus": "NONE"
    }
  }
}

当您使用alexa进行测试时,必须考虑正在测试VOICE服务,并且您正在模拟SPEECH而不是文本。 您不能亲自说出“掷出20面骰子”。 因此,如果您要掷20面骰子,则必须说“掷20面骰子”,这就是说数字20的原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM