Alexa技能ASKMODE下Help/Cancel/StopIntent处理异常求助
Hey Thom, I’ve looked over your code and the issue you’re describing—where saying "Help" in ASKMODE lands you in the PlayPitch intent instead of AMAZON.HelpIntent—is a common snag with Alexa skill state management. Let’s break down what’s going on and fix it properly.
Why This Happens
The root cause almost always boils down to one of two things:
- Overly broad utterances in your PlayPitch intent: If your interaction model’s
PlayPitchintent includes sample phrases that overlap with built-in intent triggers (like "help" or "can you help me"), Alexa’s NLP will incorrectly route those requests toPlayPitchinstead of the intended built-in intent. - Missing built-in intents in your interaction model: If you haven’t explicitly added
AMAZON.HelpIntent,AMAZON.CancelIntent, andAMAZON.StopIntentto your skill’s interaction model, Alexa won’t recognize those requests as separate intents at all.
Step 1: Fix Your Interaction Model
First, head to the Alexa Developer Console and open your skill’s Interaction Model:
- Navigate to the
Intentstab and select yourPlayPitchintent. Delete any sample utterances that include words like "help", "cancel", "stop", or phrases that could be confused with built-in triggers (e.g., change "help me play a note" to "play a note for me"). - Add the required built-in intents: Click
Add Intent, selectUse an existing intent from Alexa’s built-in library, and search forAMAZON.HelpIntent,AMAZON.CancelIntent, andAMAZON.StopIntentto add them to your model. - Save and build the interaction model before moving on to code tweaks.
Step 2: Optimize Your State Handler Code
Your followUpHandlers already has the right built-in intent definitions, but we can refine it to handle edge cases and make the logic clearer. Here’s the adjusted code:
const followUpHandlers = Alexa.CreateStateHandler("ASKMODE", { // Prioritize built-in intents first (order doesn't affect routing, but makes code easier to follow) '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'); }, '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 { // Only trigger a note-specific reprompt if the request was meant for PlayPitch const speechOutput = 'I don\'t recognize that note. '; const reprompt = 'Try saying a note like e flat.'; this.response.speak(speechOutput).listen(reprompt); } this.emit(':responseReady'); }, 'Unhandled': function () { this.response.speak('I think you asked for a note, but I don\'t understand.'); this.emit(':responseReady'); } });
Key Changes Explained
- Reordered intent handlers: While Alexa doesn’t rely on order for routing, putting built-in intents at the top makes your code more readable and emphasizes their priority.
- Refined PlayPitch fallback: When the Note slot is empty, we now clarify that we don’t recognize the note (instead of repeating general help text), which avoids confusion with the actual HelpIntent.
Final Check
After updating the interaction model and code, test your skill by:
- Launching it to enter ASKMODE.
- Saying "Help"—it should now trigger the
AMAZON.HelpIntentand play your help message. - Testing "Cancel" and "Stop" to ensure they exit the skill correctly.
This should resolve the routing issue without needing temporary workarounds.
内容的提问来源于stack exchange,提问作者Thom

