【问题标题】:Alexa intent triggered but the reply is "Sorry, I had trouble doing what you asked. Please try again."触发了 Alexa 意图,但回复是“抱歉,我在执行您要求的操作时遇到问题。请再试一次。”
【发布时间】:2020-03-30 20:30:48
【问题描述】:

我正在使用城市插槽。所以,现在我想做的是让 alexa 说出城市名称。但它不起作用。

const GetCityNameIntent = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
            && Alexa.getIntentName(handlerInput.requestEnvelope) === 'GetCityNameIntent';
    },
    handle(handlerInput) {
        const cityName = this.event.request.intent.slots.City.value;
        const speakOutput = `${cityName} is this` ;
        return handlerInput.responseBuilder
            .speak(speakOutput)
            //.reprompt(speakOutput)
            .getResponse();
    }
};

【问题讨论】:

    标签: node.js alexa alexa-skill alexa-slot


    【解决方案1】:

    您可以使用以下代码获取槽值。

    Alexa.getSlotValue(SlotName)
    

    或者,如果您想以标准方式进行,您可以执行以下操作。

    handlerInput.requestEnvelope.request.intent.slots.SlotName.value
    

    【讨论】:

      【解决方案2】:

      获取槽值:

      const cityName = handlerInput.requestEnvelope.request.intent.slots.cityName.value;
      

      我假设你的 slotName 是 cityName 这里。

      const speakOutput = cityName + ' is here';
      

      【讨论】:

        猜你喜欢
        • 2020-03-23
        • 2021-02-01
        • 2016-02-11
        • 1970-01-01
        • 1970-01-01
        • 2014-06-06
        • 2021-08-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多