def handle(self, handler_input): # type: (HandlerInput) -> Response i18n = get_i18n(handler_input) speech_text = " " + i18n.get_random_goodbye() handler_input.response_builder.speak( speech_text).set_should_end_session(True) return handler_input.response_builder.response
def handle(self, handler_input, exception): rb = handler_input.response_builder i18n = get_i18n(handler_input) print("CATCH EXCEPTION") sess_attrs = handler_input.attributes_manager.session_attributes sess_attrs.clear() speech = i18n.EXCEPTION_RETRIEVING_PHONE_NUM print_traceback(exception) rb.speak(speech).set_should_end_session(True) return rb.response
def handle(self, handler_input) -> Response: self.sess_attrs = handler_input.attributes_manager.session_attributes self.i18n = get_i18n(handler_input) self.pyrogram_manager = PyrogramManager(StateManager(handler_input)) self.handler_input = handler_input if self.pyrogram_manager.get_is_authorized(): return handler_input.response_builder.speak(self.i18n.ALREADY_AUTHORIZED) \ .set_should_end_session(True).response slots = handler_input.request_envelope.request.intent.slots code = slots.get('code').value if code: return self.try_to_sign_user_in(code) return self.send_code()
def process(self, handler_input, response): sess_attrs = handler_input.attributes_manager.session_attributes i18n = get_i18n(handler_input) if response.output_speech: response.card = SimpleCard( title=i18n.SKILL_NAME, content=remove_ssml_tags(response.output_speech.ssml) ) if sess_attrs.get('show_permission_consent_card', False): sess_attrs['show_permission_consent_card'] = False response.card = AskForPermissionsConsentCard( ['alexa::profile:mobile_number:read'] )
def handle(self, handler_input): sess_attrs = handler_input.attributes_manager.session_attributes intent_to_explore = sess_attrs.get("explore_intent", "") i18n = get_i18n(handler_input) if intent_to_explore == ExploreIntents.EXPLORE_SETUP_INTENT: slots = {"code": Slot(name="code")} intent = Intent(name='SetupIntent', slots=slots) handler_input.response_builder.add_directive(DelegateDirective(updated_intent=intent)) return handler_input.response_builder.response if intent_to_explore == ExploreIntents.EXPLORE_MESSAGE_INTENT: intent = Intent(name='MessageIntent') handler_input.response_builder.add_directive(DelegateDirective(updated_intent=intent)) return handler_input.response_builder.response return handler_input.response_builder.speak(i18n.SUGGEST_WHAT_TO_DO).ask(i18n.FALLBACK).response
def handle(self, handler_input): sess_attrs = handler_input.attributes_manager.session_attributes self.i18n = get_i18n(handler_input) pyrogram_manager = PyrogramManager(StateManager(handler_input)) if not pyrogram_manager.get_is_authorized(): return handler_input.response_builder.speak( self.i18n.NOT_AUTHORIZED).set_should_end_session(True).response if 'unread_dialogs' not in sess_attrs: unread_dialogs = pyrogram_manager.get_unread_dialogs() sess_attrs['unread_dialogs'] = unread_dialogs if not unread_dialogs: speech = self.i18n.NO_NEW_TELEGRAMS + ' ' + self.i18n.get_random_goodbye( ) return handler_input.response_builder.speak(speech).response unread_dialogs_index = sess_attrs.get('unread_dialog_index', 0) unread_dialogs = sess_attrs.get('unread_dialogs', []) speech_text = '' if unread_dialogs_index == 0: first_names = self.get_first_names(unread_dialogs) speech_text += self.i18n.NEW_TELEGRAMS_FROM.format(first_names) dialog = unread_dialogs[unread_dialogs_index] pyrogram_manager.read_history(dialog['chat_id']) speech_text += self.construct_output_speech_for_dialog(dialog) if unread_dialogs_index == len(unread_dialogs) - 1: speech_text += self.i18n.BREAK_2000 + ' ' + self.i18n.NO_MORE_TELEGRAMS return handler_input.response_builder.speak( speech_text).set_should_end_session(True).response speech_text += self.i18n.BREAK_2000 + ' ' + self.i18n.NEXT_TELEGRAMS sess_attrs['unread_dialog_index'] = unread_dialogs_index + 1 return handler_input.response_builder.speak(speech_text).ask( self.i18n.FALLBACK).response
def handle(self, handler_input: HandlerInput) -> Response: sess_attrs = handler_input.attributes_manager.session_attributes i18n = get_i18n(handler_input) pyrogram_manager = PyrogramManager(StateManager(handler_input)) if not pyrogram_manager.get_is_authorized(): set_explore_sess_attr(sess_attrs, ExploreIntents.EXPLORE_SETUP_INTENT) return handler_input.response_builder.speak(i18n.NEW_SETUP).ask( i18n.FALLBACK).response unread_dialogs = pyrogram_manager.get_unread_dialogs() if unread_dialogs: speech = i18n.WELCOME_BACK + ' ' + i18n.NEW_TELEGRAMS set_explore_sess_attr(sess_attrs, ExploreIntents.EXPLORE_MESSAGE_INTENT) sess_attrs['unread_dialogs'] = unread_dialogs return handler_input.response_builder.speak(speech).ask( i18n.FALLBACK).response speech = i18n.WELCOME_BACK + ' ' + i18n.NO_NEW_TELEGRAMS + ' ' + i18n.get_random_anyting_else( ) return handler_input.response_builder.speak(speech).ask( i18n.FALLBACK).response
def handle(self, handler_input): # type: (HandlerInput) -> Response i18n = get_i18n(handler_input) return handler_input.response_builder.speak( i18n.SUGGEST_WHAT_TO_DO).ask(i18n.FALLBACK).response
def handle(self, handler_input): i18n = get_i18n(handler_input) return handler_input.response_builder.speak(i18n.LEARN_MORE).set_should_end_session(True).response