HelpIntent、CancelIntent 和 StopIntent

HelpIntent, CancelIntent, and StopIntent

这是我的第一个认证。我的技能很简单。我已经注册了两个处理程序:

const handlers = {
    'LaunchRequest': function () {
      this.handler.state = "ASKMODE";
      this.emit(':ask',
                'Ask me to play a musical note, for example, say C sharp');
    },
    'Unhandled': function () {
        this.response.speak('I do not know how to proceed. Try asking for a note like, alexa, ask pitch pipe to give me a d flat.');
        this.emit(':responseReady');
    },
    'PlayPitch': function () {
        const noteSlot = this.event.request.intent.slots.Note;
        let noteName;
        if (noteSlot && noteSlot.value) {
            noteName = noteSlot.value.toLowerCase();
            var speech = resultingSpeech(noteName);
            this.response.speak(speech);
        }
        else {
            this.response.speak('I don\'t know that note.');
        }

        this.emit(':responseReady');
    }
};

const followUpHandlers = Alexa.CreateStateHandler("ASKMODE", {
    'PlayPitch': function () {
        const noteSlot = this.event.request.intent.slots.Note;
        let noteName;
        if (noteSlot && noteSlot.value) {
          noteName = noteSlot.value.toLowerCase();
          var speech = resultingSpeech(noteName);
          this.response.speak(speech);
        }
        else {
          const speechOutput = 'Pitch Pipe will play any note of the 12 tone scale surrounding A440 ';
          const reprompt = 'Simply speak the name of a note, such as e flat.';

          this.response.speak(speechOutput).listen(reprompt);
          this.emit(':responseReady');
        }

        this.emit(':responseReady');
    },
    'AMAZON.HelpIntent': function () {
          const speechOutput = 'Pitch Pipe will play any note of the 12 tone scale surrounding A440 ';
          const reprompt = 'Simply speak the name of a note, such as e flat.';

          this.response.speak(speechOutput).listen(reprompt);
          this.emit(':responseReady');
    },
    'AMAZON.CancelIntent': function () {
        this.response.speak('Goodbye!');
        this.emit(':responseReady');
    },
    'AMAZON.StopIntent': function () {
        this.response.speak('See you later!');
        this.emit(':responseReady');
    },
    'Unhandled': function () {
        this.response.speak('I think you asked for a note, but I don\'t understand.');
        this.emit(':responseReady');
    }
});

因此处理程序上的原始 LaunchRequest 工作正常,当它在 ASKMODE 中返回时,它会转到带有 PitchPipe 意图的 followUpHandlers,这也工作正常。

问题在于处理 help/cancel/stop。如果在 ASKMODE 中,您说 "Help" 它返回到 PitchPipe 意图,但槽中没有任何值。我现在已经破解它来处理帮助,但无法弄清楚它应该如何工作。

这个问题是因为我保存了我的交互模型,但没有构建它。一旦我建立了交互模型,一切都很完美。

赞!