0
votes

Friends,

I'm working on an Alexa skill that attempts to stream an mp3 file from a publicly accessible S3 bucket. My lambda function is working correctly, and returns an audio directive. I'm using the npm package alexa-sdk.

However when the response is sent back to the Echo device, I'm getting a generic error of "there was an error with your skills response." I Googled for some type of Alexa response lintet to try and validate my response object.

Below is my lambda function IntentHandler, and the response object being returned from said function. Can someone take a look and point out any errors they see? It's much appreciated.

var handlers = {
'LaunchRequest': function () {
    this.emit(':tell', 'Hello');
},
GetVoiceMailIntent: function(){
    this.response.audioPlayerPlay('REPLACE_ALL', 'https://s3.amazonaws.com/romevm/call_1001.mp3', 'vmtoken', 0);
    this.emit(':responseReady');
},
SessionEndedRequest: function () {
console.log('session ended!');
} 
} //end intent handlers

*********** RESPONSE **************
{
  "version": "1.0",
  "response": {
   "speechletResponse": {
     "directives": [
    {
      "playBehavior": "REPLACE_ALL",
      "audioItem": {
        "stream": {
          "expectedPreviousToken": "0",
          "token": "vmtoken",
          "url": "https://s3.amazonaws.com/romevm/call_1001.mp3",
          "offsetInMilliseconds": 0
        }
      }
    }
  ],
  "shouldEndSession": true
  }
 },"sessionAttributes": {}
}
1

1 Answers

1
votes

According to the AudioPlayer Directives Documentation, when sending AudioPlayer directives to the server you must set the type property and include it in the directives array of your response. And according to your example, you are not doing so.

In your example, before the key playBehavior, you should add the following key:

"type": "AudioPlayer.Play",

Also, make sure your audio complies with Amazon's requirements:

The supported formats for the audio file include AAC/MP4, MP3, HLS, PLS and M3U. Bitrates: 16kbps to 384 kbps.