Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fallback Handler to send ResponseNone to Home Assistant if there is no response or the skill could not understand the response #259

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lambda/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,22 @@ def handle(self, handler_input):

return _handle_response(handler_input, speak_output)

class FallbackHandler(AbstractRequestHandler):
"""Handler for Fallback."""

def can_handle(self, handler_input):
"""Check for Select Intent."""
return is_intent_name("AMAZON.FallbackIntent")(handler_input)

def handle(self, handler_input):
"""Handle Fallback."""
logger.info("Fallback Handler triggered")
ha_obj = HomeAssistant(handler_input)
#reason = handler_input.request_envelope.request.reason
#if reason == SessionEndedReason.EXCEEDED_MAX_REPROMPTS or reason == SessionEndedReason.USER_INITIATED:
ha_obj.post_ha_event(RESPONSE_NONE, RESPONSE_NONE)

return handler_input.response_builder.response

class SessionEndedRequestHandler(AbstractRequestHandler):
"""Handler for Session End."""
Expand Down Expand Up @@ -655,6 +671,7 @@ def process(self, handler_input):
sb.add_request_handler(DurationIntentHandler())
sb.add_request_handler(DateTimeIntentHandler())
sb.add_request_handler(CancelOrStopIntentHandler())
sb.add_request_handler(FallbackHandler())
sb.add_request_handler(SessionEndedRequestHandler())
sb.add_request_handler(IntentReflectorHandler())

Expand Down
Loading