alexa
alexa copied to clipboard
alexa-response: Enforce runtime requirements
There are some requirements I learned the hard way, when using alexa-response. Perhaps we should enforce these in code so that others get an immediate exception or Error if they don't meet these requirements... it is time consuming and tricky to discover this stuff from CloudWatch logs:
- You can only have one audio directive per response. If you try to add more than one, it fails.
- The URL in an audio directive has to be https. If you give an http URL, it fails.
- A token is required for each audioItem in an audio directive. If you don't provide one, it fails.
- If you provide an audioItem with playBehavior ENQUEUE (i.e. AudioPlayer.enqueue in alexa-response) then you also need to provide an expectedPreviousToken for your audioItem and this needs to match the token of the immediately preceding audiotItem.
If I discover any other runtime requirements I will add them here but these are the ones I ran into so far. Would be great to enforce these somehow for the caller, e.g. when you do a .build() it could throw an error if any of these requirements are not met.
This is probably not super critical, but a nice to have for now.