def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In YesMoreInfoIntentHandler")
        if not util.TIMETABLE_DATA:
            # set up TIMETABLE_DATA
            logger.info("Setting up timetable data")
            util.process_ical_file()

        attribute_manager = handler_input.attributes_manager
        session_attr = attribute_manager.session_attributes
        _ = attribute_manager.request_attributes["_"]

        # the lecture was stored as a session attribute in the earlier function
        lecture = session_attr[lecture_location_key]
        building = util.convertBuildingCode(lecture["location_campus"],
                                            lecture["location_building"])
        campus = util.convertCampusCode(lecture["location_campus"])

        speech = (
            "{} is on {} campus. Your lecture is in room {}. I have sent these details to the Alexa app on your phone."
        ).format(building, campus, lecture["location_room"])

        card_info = ("Room: {} \n Building: {} \n Campus: {}").format(
            lecture["location_room"], building, campus)

        handler_input.response_builder.speak(speech).set_card(
            SimpleCard(title=(data.SKILL_NAME), content=card_info))
        return handler_input.response_builder.response
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In BeforeLectureIntentHandler")
        if not util.TIMETABLE_DATA:
            # set up TIMETABLE_DATA
            logger.info("Setting up timetable data")
            util.process_ical_file()

        attribute_manager = handler_input.attributes_manager
        session_attr = attribute_manager.session_attributes

        lecture = util.findNextLecture()
        if not lecture:
            # if there aren't any more lectures on the timetable
            speech = ("There are no more lectures on your timetable.")
        else:
            # save the lecture to be used in the YesMoreInfoIntentHandler
            handler_input.attributes_manager.session_attributes[
                lecture_location_key] = lecture

            time = lecture['time']
            room = lecture['location_room']
            building = lecture['location_building']
            building = util.convertBuildingCode(lecture["location_campus"],
                                                building)
            date = lecture['date']

            speech = (
                "Your next lecture is in room {} in {} at {}. Would you like more information about where that is?"
            ).format(room, building, time)
        reprompt = "Would you like more information about where that is?"
        handler_input.response_builder.speak(speech).ask(reprompt)
        return handler_input.response_builder.response
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In HelpIntentHandler")
        if not util.TIMETABLE_DATA:
            # set up TIMETABLE_DATA
            logger.info("Setting up timetable data")
            util.process_ical_file()
        _ = handler_input.attributes_manager.request_attributes["_"]

        handler_input.response_builder.speak((data.HELP)).ask((data.HELP))
        return handler_input.response_builder.response
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In NoMoreInfoIntentHandler")
        if not util.TIMETABLE_DATA:
            # set up TIMETABLE_DATA
            logger.info("Setting up timetable data")
            util.process_ical_file()

        speech = ("Ok.")
        # handler_input.response_builder.speak(speech).ask(speech)
        handler_input.response_builder.speak(speech)
        return handler_input.response_builder.response
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In LaunchRequestHandler")
        _ = handler_input.attributes_manager.request_attributes["_"]
        if not util.TIMETABLE_DATA:
            # set up TIMETABLE_DATA
            logger.info("Setting up timetable data")
            util.process_ical_file()

        speech = (data.WELCOME)
        speech += " " + (data.HELP)
        handler_input.response_builder.speak(speech)
        handler_input.response_builder.ask((data.GENERIC_REPROMPT))
        return handler_input.response_builder.response
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In FirstLectureIntentHandler")
        if not util.TIMETABLE_DATA:
            # set up TIMETABLE_DATA
            logger.info("Setting up timetable data")
            util.process_ical_file()
        attribute_manager = handler_input.attributes_manager
        session_attr = attribute_manager.session_attributes

        # access the slot value to be searched
        slots = handler_input.request_envelope.request.intent.slots
        if first_slot in slots:
            # check if the value in the slot is valid
            if slots[first_slot].value != None:
                logger.info("Inside the first_slot section")
                day_to_search = slots[first_slot].value

                # get the first lecture of the day
                events_on_day = util.searchByDate(day_to_search)

                if not events_on_day:
                    speech = ("You don't have any lectures on {}"
                              ).format(day_to_search)
                else:
                    weekday = util.convertToWeekday(
                        events_on_day[0]['start_time'])
                    speech = (
                        "Your first lecture on {} {} is {} at {}. ").format(
                            weekday, day_to_search, events_on_day[0]["module"],
                            events_on_day[0]["time"])
                    # Calculate how long it is until the lecture starts
                    time_until_lecture = util.timeUntilLecture(
                        events_on_day[0])
                    if (time_until_lecture != -1):
                        # if the lecture is not in the past
                        speech += ("That is in {}.").format(time_until_lecture)
                    else:
                        speech += ("That is in the past.")

            else:
                speech = "I'm not sure what day you asked about. Please try again."
        else:
            # the slot was empty
            logger.info("In the else section")
            speech = "I'm not sure what day you asked about. Please try again."

        handler_input.response_builder.speak(speech)
        return handler_input.response_builder.response
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In NextLectureIntentHandler")
        if not util.TIMETABLE_DATA:
            # set up TIMETABLE_DATA
            logger.info("Setting up timetable data")
            util.process_ical_file()

        # get the value of the next lecture to happen
        next_lecture = util.findNextLecture()

        if not next_lecture:
            # if there are no lectures in the future
            speech = ("There are no more lectures on your timetable.")
        else:
            time_until_lecture = util.timeUntilLecture(next_lecture)
            speech = ("Your next lecture is {} at {}. That is in {}.").format(
                next_lecture["module"], next_lecture["time"],
                time_until_lecture)

        handler_input.response_builder.speak(speech)
        return handler_input.response_builder.response
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In WeekOverviewOrDetailedDayIntentHandler")
        if not util.TIMETABLE_DATA:
            # set up TIMETABLE_DATA
            logger.info("Setting up timetable data")
            util.process_ical_file()

        # access the slot value for the day to be searched
        slots = handler_input.request_envelope.request.intent.slots
        if day_slot in slots:
            # check if the value in the slot was valid.
            if slots[day_slot].value != None:
                logger.info("Inside the day_slot section")
                logger.info(slots[day_slot].value)
                value_to_search = slots[day_slot].value

                if ("W" in value_to_search):
                    # then the slot is a week value
                    # find the event on that day
                    week_events = util.findLecturesOnWeek(value_to_search)
                    if not week_events:
                        # if there are no lectures that week
                        speech = (
                            "You have no events {}").format(value_to_search)
                    else:
                        length = len(week_events)
                        speech = ("You have ")
                        for i in range(length):
                            if (length > 1 and i == length - 1):
                                # if there is more than one day with events
                                speech += "and "
                            speech += ("{}").format(
                                week_events[i]["num_of_lectures"])
                            if (week_events[i]["num_of_lectures"] == 1):
                                # if there is only one lecture on that day then lecture does not need to be plural
                                speech += " lecture "
                            else:
                                speech += " lectures "

                            speech += ("on {} between {} and {}, ").format(
                                week_events[i]["weekday"],
                                week_events[i]["day_start"],
                                week_events[i]["day_end"])
                else:
                    # the slot is a date value for an individual day
                    events = util.searchByDate(value_to_search)

                    if not events:
                        # if there are no lectures on that day
                        speech = (
                            "You have no events on {}").format(value_to_search)
                    else:
                        # find Weekday

                        weekday = util.convertToWeekday(
                            events[0]['start_time'])
                        length = len(events)
                        speech = ("On {} {} you have ").format(
                            weekday, value_to_search)
                        for i in range(length):
                            if (length > 1 and i == length - 1):
                                speech += ("and ")
                            speech += ("a {} hour {} {} at {}, ").format(
                                events[i]["duration_hours"],
                                events[i]["module"], events[i]["type"],
                                events[i]["time"])
            else:
                speech = "I'm not sure what day or week you asked about. Please try again."
        else:
            # the slot was empty
            logger.info("In the else section")
            speech = "I'm not sure what day or week you asked about. Please try again."

        handler_input.response_builder.speak(speech)
        return handler_input.response_builder.response