【问题标题】:How to clear custom slot value programmatically in Alexa?如何在 Alexa 中以编程方式清除自定义插槽值?
【发布时间】:2018-01-04 07:09:47
【问题描述】:

我有一项 Alexa 技能,需要以编程方式覆盖用户提供的值。

我已尝试使该值无效,然后将其作为“更新的 Intent”传递。

this.event.request.intent.userPrompt.value = null;
var updatedIntent = this.event.request.intent;
this.emit(':elicitSlot', 'userPrompt',"Say something","Say something", updatedIntent);

但是,输入 JSON 显示之前的值。有解决办法吗?

【问题讨论】:

    标签: javascript alexa alexa-skills-kit alexa-skill alexa-slot


    【解决方案1】:

    delete this.event.request.intent.slots.<slotname>.value;
    var updatedIntent = this event.request.intent;
    this.emit(':elicitSlot', <slotname>,"Say something","Say something", updatedIntent);
    

    如果你有一个自定义插槽类型的插槽,你还必须

    delete this.event.request.intent.slots.<slotname>.resolutions;
    

    【讨论】:

    • 谢谢@A.Kraus。这按预期工作。你为我节省了很多时间。
    【解决方案2】:

    对于版本 V2,您应该以这种方式更新意图(据我所知)

     handlerInput.responseBuilder
        .addDelegateDirective(newIntent)
        .getResponse();
    

    newIntent 应该是一个可以设置新槽值的对象,例如:

    
    const resetIntent = (handlerInput) => {
      const intent = {
        name : 'myIntentName',
        confirmationStatus: 'NONE',
        slots : {
          slotOne: {
            name: 'slotOne',
            confirmationStatus: 'NONE'
          }
        }
      }
    
      return handlerInput.responseBuilder
        .addDelegateDirective(intent)
        .getResponse();
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-13
      相关资源
      最近更新 更多