Alexa ResumeIntent/PauseIntent返回Null SpeechletResponse错误求助
Fixing Alexa's Null SpeechletResponse Error for Resume/Pause Intents
Hey there, let's break down why you're hitting that Null SpeechletResponse error and fix your ResumeIntent and PauseIntent code step by step:
1. First, Fix Your AMAZON.ResumeIntent Response
Your current ResumeIntent code is missing critical required fields for the AudioPlayer.Play directive, and your shouldEndSession setting isn't ideal for audio skills. Here's the corrected version:
if intent == "AMAZON.ResumeIntent": # Tip: Store the paused stream's details (token, URL, offset) in sessionAttributes when pausing # This example uses your test values—replace these with actual stored data paused_stream = { "token": "12345", "url": "https://s3.amazonaws.com/jingle.mp3", "offsetInMilliseconds": 0 # Use the actual offset saved when paused } return { "version": "1.0", "sessionAttributes": {}, # Save playback state here for future use "response": { "outputSpeech": { "type": "PlainText", "text": "Resuming your audio" }, "directives": [ { "type": "AudioPlayer.Play", "playBehavior": "REPLACE_ALL", # Correct behavior for resuming playback "audioItem": { "stream": paused_stream } } ], "shouldEndSession": False # Keep the session open so users can control playback } }
Key Fixes:
- Added
playBehaviorandaudioItemto theAudioPlayer.Playdirective—Alexa can't resume playback without knowing which stream to pick up and how to handle it. - Set
shouldEndSessiontoFalse—audio skills need the session open so users can send pause/stop commands mid-playback. - Make sure to store the paused stream's offset and token in
sessionAttributeswhen handling PauseIntent, so Resume can pick up exactly where the user left off.
2. Fix Your AMAZON.PauseIntent Response
This is where the Null SpeechletResponse error is likely coming from—your response is missing mandatory top-level fields, uses the wrong AudioPlayer directive, and includes unnecessary parameters. Here's the corrected code:
if intent == "AMAZON.PauseIntent": # Get the current playback offset from Alexa's request (you'll need to parse this) current_offset = 0 # Replace with actual offset from the request return { "version": "1.0", # Mandatory top-level field—can't skip this! "sessionAttributes": { "currentOffset": current_offset, "audioToken": "12345" # Save stream details for ResumeIntent }, "response": { "outputSpeech": { "type": "PlainText", "text": "Paused" }, "directives": [ { "type": "AudioPlayer.Pause" # Use Pause, not Stop—Stop clears the playback queue } ], "shouldEndSession": False } }
Key Fixes:
- Added the mandatory
versionandsessionAttributestop-level fields—Alexa requires these in every response, even ifsessionAttributesis empty. Missing them causes the Null SpeechletResponse error directly. - Swapped
AudioPlayer.StopforAudioPlayer.Pause:Stopis for ending playback entirely and clearing the queue, whilePauseis for pausing temporarily so users can resume later. - Removed unnecessary
playBehaviorandaudioItemfields—AudioPlayer.Pausedoesn't need these, and extra invalid fields will break the response. - Stored the current playback offset in
sessionAttributesso ResumeIntent can pick up where things left off.
Quick General Tips
- Always validate your response against Alexa's official response schema—missing mandatory fields or including invalid parameters is the #1 cause of Null SpeechletResponse errors.
- When testing, use the Alexa Developer Console's test panel first—it shows detailed request/response logs that make it easy to spot missing fields or invalid directives, which is way faster than testing only on a Fire tablet.
- For audio skills, keep
shouldEndSessionset toFalseduring playback so users can control audio without re-invoking the skill.
内容的提问来源于stack exchange,提问作者Jonathan
相关产品推荐
相关产品推荐

