Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
When an SessionEndedRequest is processed by the Alexa module, a "500 Internal Server Error" response is returned, due to the request not being handled, and thus having an empty response. This results in Alexa speaking that there was a problem. This makes for a poor UX.
Proposed resolution
Return a "200 OK" HTTP response, instead, when no response content is returned from any modules' hook_alexa_callback(), (i.e. when the response is empty).
Remaining tasks
Comment | File | Size | Author |
---|---|---|---|
#6 | alexa_says_there_was_a-2876157-6.patch | 1.09 KB | hampercm |
Comments
Comment #2
hampercm CreditAttribution: hampercm at Acquia commentedComment #3
hampercm CreditAttribution: hampercm at Acquia commentedComment #4
gambryI can't find best practices for this scenario.
I feel a 500 is a clear statement about something wrong on the development side (i.e. an Intent not implemented).
Are there any other cases where an empty content is returned, other than an intent non processed?
Comment #5
hampercm CreditAttribution: hampercm at Acquia commentedResponses might not have any outputSpeech (for example a response with only ->endSession() applied is valid and useful). I adjusted the patch accordingly.
This will also prevent Alexa from announcing an error if no plugin handled the given Alexa request. Alexa will now quietly end the session instead in that case. A developer can still add code to their custom Alexa plugin to do so if announcing an error in this case is desired.
Comment #6
hampercm CreditAttribution: hampercm at Acquia commentedThis patch handles the lack of any response returned from a plugin in a more straightforward manner. I think it's important to do things this way, rather than returning a 500 response if a request isn't handled, to improve DX for those new to Alexa. If the developer doesn't handle a LaunchRequest or SessionEndRequest in their plugin, for example, that would cause a 500 error that might only cause confusion.
Improvements I'm making to the alexa_demo module will hopefully reduce the likelihood of this kind of confusion. For now, I'm siding on an architecture that is forgiving to new developers.
Comment #8
hampercm CreditAttribution: hampercm at Acquia commented