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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hampercm created an issue. See original summary.

hampercm’s picture

Issue summary: View changes
hampercm’s picture

Title: Alexa says "there was a problem communicating with the skill" on EndSessionIntent » Alexa says "there was a problem communicating with the skill" on SessionEndedRequest
Assigned: hampercm » Unassigned
Issue summary: View changes
Status: Active » Needs review
FileSize
652 bytes
gambry’s picture

I 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?

hampercm’s picture

FileSize
1.41 KB

Responses 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.

hampercm’s picture

FileSize
1.09 KB

This 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.

  • hampercm committed 5049178 on 7.x-1.x
    Issue #2876157 by hampercm: Alexa says "there was a problem...
hampercm’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.