question

Bala Yogesh avatar image
Bala Yogesh asked

Expecting request type of IntentRequest but got AudioPlayer.PlaybackStarted

Why I am getting this error and after this occured system error encountered happen.
1677500976123.png

audioplayeralexa skillsaudio playback
1677500976123.png (54.3 KiB)
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Andy Whitworth avatar image
Andy Whitworth answered

That is because one of your registered handlers is using the Alexa SDK utility function getIntentName() in it's canHandle() function without first checking if the request type is an IntentRequest.

What is happening is that an AudioPlayer.PlaybackStarted request is being received by your lambda function and the Alexa SDK is running through all of the registered handlers looking for the first one which returns true in it's canHandle() function. It is coming across a handler which is doing as I describe in the first paragraph.

When checking for an Intent name match, you should always check that the request type is an IntentRequest first, otherwise such issues can arise.

Obvioiusly you're going to need a handler for the AudioPlayer.PlaybackStarted request too + all the other required AudioPlayer request types. Presumably you're basing the skill on an Amazon audio player example ? If so then it should have all that you require.

2 comments
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bala Yogesh avatar image Bala Yogesh commented ·

Thanks for the reply. let me check on that. Yes, I followed that one.

Like this Alexa.getRequestType(handlerInput.requestEnvelope) === "IntentRequest" ?

0 Likes 0 ·
Andy Whitworth avatar image Andy Whitworth Bala Yogesh commented ·

This is what I do when checking for intent matches.

const HelpHandler = {
   
 canHandle(handlerInput) {
   
 const { requestEnvelope } = handlerInput;
 return (
        Alexa.getRequestType(requestEnvelope) === "IntentRequest" &&
        Alexa.getIntentName(requestEnvelope) === "AMAZON.HelpIntent"
    );
 },
0 Likes 0 ·