コード例 #1
0
    def handle(self, handler_input):
        """Handler for Skill Launch.
        Get the persistence attributes, to figure out the game state.
        """
        log_status(handler_input, "No")
        # type: (HandlerInput) -> Response
        attr = handler_input.attributes_manager.session_attributes
        print("NoIntent handled\n", str(attr))
        if attr['current_stage'] == "GREETING":
            handler_input = GREETING(handler_input, ans=0).handle()

        elif attr['current_stage'] == BreathExercise.short_name:
            handler_input = BreathExercise(handler_input, ans=0).handle()

        elif attr['current_stage'] == RESCHEDULE.short_name:
            handler_input = RESCHEDULE(handler_input, ans=0).handle()

        # handler_input.response_builder.speak(prompt).set_card(
        #     SimpleCard("Hello World", prompt)).set_should_end_session(
        #     True).ask(reprompt)
        return handler_input.response_builder.response
コード例 #2
0
    def handle(self, handler_input):
        """Handler for Skill Launch.
        Get the persistence attributes, to figure out the game state.
        """

        current_intent = handler_input.request_envelope.request.intent
        log_status(handler_input, str(current_intent))
        attr = handler_input.attributes_manager.session_attributes
        # print(current_intent)
        # print(current_intent.confirmation_status)
        if current_intent.confirmation_status == IntentConfirmationStatus.DENIED:
            attr["current_stage"] = RESCHEDULE.short_name
            attr["step"] = -1
            handler_input = RESCHEDULE(handler_input, ans=0).handle()
            handler_input.response_builder.speak(prompt).set_card(
                SimpleCard("Hello World",
                           prompt)).set_should_end_session(True).ask(reprompt)
            return handler_input.response_builder.response
        if current_intent.confirmation_status == IntentConfirmationStatus.CONFIRMED:

            prompt = "Thanks, we will reschedule your time"
            handler_input.response_builder.speak(prompt).set_card(
                SimpleCard("Hello World", prompt)).set_should_end_session(True)
            return handler_input.response_builder.response
コード例 #3
0
if __name__ == "__main__":
    args = handle_args()
    QUEUE_IN = Q_IN_NAME_BASE + args.suffix  #reset the name of of the qin to add suffix
    #print QUEUE_IN
    TABLE_NAME = TABLE_NAME_BASE + args.suffix  #reset the name of the table to add suffix
    #creating qin, qout and table-----------------------------------------------------------------
    qin = create_q(QUEUE_IN)
    qout = create_q(constants.Q_OUT_NAME)
    global nextTopNum  #this is next expected op num, starts at 1
    nextTopNum = 1
    requestList = []  #we use a dictonary to store out of order msg
    global msgIDList  #we choose to use a dictionary to track operations, the msg_id is the key, output response is the stored value
    msgIDList = {}
    request = {}  #creating globa(while loop) request variable
    main()  #connect to table
    log_status("#########    BACKEND RUNNING    ##########")
    while True:
        #always check to see if the next expected op is stored first
        #If it's found, skip read in from inqueue
        skip_read_in = 0
        index = 0
        for req in requestList:
            if req['opnum'] <= nextTopNum:
                request = req
                skip_read_in = 1
                requestList.pop(index)
                #del requestList[operation]
                break
            index += 1

        #If it's not found, reading in from qin
コード例 #4
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        speech_text = data.WELCOME_MESSAGE
        attr = handler_input.attributes_manager.session_attributes
        # p_attr = handler_input.attributes_manager.persistent_attributes

        # Request Permission
        request_envelope = handler_input.request_envelope
        permissions = request_envelope.context.system.user.permissions
        reminder_service = handler_input.service_client_factory.get_reminder_management_service(
        )

        # if not (permissions and permissions.consent_token):
        #     print("user hasn't granted reminder permissions")
        #     return handler_input.response_builder.speak("Please give permissions to set reminders using the alexa app.") \
        #         .set_card(AskForPermissionsConsentCard(permissions=REQUIRED_PERMISSIONS)) \
        #         .response

        # # Set every day reminder
        # now = datetime.datetime.now(tz)
        # print(now)
        # notification_time = now.replace(hour=8, minute=0, second=0) + timedelta(days=1)
        # notification_time = notification_time.strftime(time_format)
        # print(notification_time)
        # re = recurrence.Recurrence(recurrence_freq.RecurrenceFreq.DAILY)
        # trigger = Trigger(TriggerType.SCHEDULED_ABSOLUTE, notification_time, time_zone_id=TIME_ZONE_ID, recurrence=re)
        # text = SpokenText(locale='en-US', ssml="Would you like some mindfulness exercise? Please say open happy day.",
        #         text='Would you like some mindfulness exercise? Please say open happy day.')
        # alert_info = AlertInfo(SpokenInfo([text]))
        # push_notification = PushNotification(PushNotificationStatus.ENABLED)
        # reminder_request = ReminderRequest(now.strftime(time_format), trigger, alert_info, push_notification)
        #
        # try:
        #     rs = reminder_service.get_reminders()
        #     print("existing reminders:",rs)
        # except ServiceException as e:
        #     # see: https://developer.amazon.com/docs/smapi/alexa-reminders-api-reference.html#error-messages
        #     print("Error in get_reminders")
        #     print(e)
        #     traceback.print_exc()
        # try:
        #     reminder_response = reminder_service.create_reminder(reminder_request)
        # except ServiceException as e:
        #     # see: https://developer.amazon.com/docs/smapi/alexa-reminders-api-reference.html#error-messages
        #     print("Error in creating reminder while launching")
        #     print(e)
        #     traceback.print_exc()

        if not attr:
            # First YesIntent route to "BREATH_EX"
            attr['current_stage'] = "GREETING"
            attr['step'] = -1  # This is for next-level route

        try:
            user_preferences_client = handler_input.service_client_factory.get_ups_service(
            )
            user_name = user_preferences_client.get_profile_name()
        except:
            user_name = "friend"
            print("Cannot get user_name")

        attr['name'] = user_name
        handler_input = GREETING(handler_input).handle()

        log_status(handler_input, "Launch")
        return handler_input.response_builder.response