Exemplo n.º 1
0
def in_progress_choose_sceanrio_request(handler_input, minus_points,
                                        quit_minus_points):
    session_attributes = handler_input.attributes_manager.session_attributes
    user = handler_input.request_envelope.context.system.user.user_id
    active_scenario = ActiveScenario.objects.get(user=user)

    # if box was opened in game
    if not session_attributes.get('box') and active_scenario.box:
        return cancel_and_stop_request(handler_input, quit_minus_points)

    # only ask how many persons will participate if scenario is selected
    if not session_attributes.get('scenario'):
        try:
            slots = handler_input.request_envelope.request.intent.slots
            scenario_slot = slots.get('scenario').value if slots.get(
                'scenario') else None
            Scenario.objects.get(
                other_names__contains=scenario_slot) if scenario_slot else None
        except Scenario.DoesNotExist:
            return fallback_request(handler_input, minus_points,
                                    quit_minus_points)

        current_intent = handler_input.request_envelope.request.intent
        return handler_input.response_builder.add_directive(
            DelegateDirective(updated_intent=current_intent)).response
    else:
        return fallback_request(handler_input, minus_points, quit_minus_points)
Exemplo n.º 2
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In InProgressHowMuchIntent")
        current_intent = handler_input.request_envelope.request.intent

        return handler_input.response_builder.add_directive(
            DelegateDirective(updated_intent=current_intent)).response
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In InProgressEcDescribeTagsIntent")
        current_intent = handler_input.request_envelope.request.intent
        prompt = ""

        for slot_name, current_slot in six.iteritems(current_intent.slots):
            if slot_name in ["EcInstanceNameSelector"]:
                if (current_slot.confirmation_status != SlotConfirmationStatus.CONFIRMED
                        and current_slot.resolutions
                        and current_slot.resolutions.resolutions_per_authority[0]):
                    if current_slot.resolutions.resolutions_per_authority[0].status.code == StatusCode.ER_SUCCESS_MATCH:
                        if len(current_slot.resolutions.resolutions_per_authority[0].values) > 1:
                            prompt = "Select "

                            values = " or ".join([e.value.name for e in current_slot.resolutions.resolutions_per_authority[0].values])
                            prompt += values + " ?"
                            return handler_input.response_builder.speak(
                                prompt).ask(prompt).add_directive(
                                    ElicitSlotDirective(slot_to_elicit=current_slot.name)
                                    ).response
                    elif current_slot.resolutions.resolutions_per_authority[0].status.code == StatusCode.ER_SUCCESS_NO_MATCH:
                        if current_slot.name in required_slots:
                            prompt = "What {} are you looking for?".format(current_slot.name)

                            return handler_input.response_builder.speak(
                                prompt).ask(prompt).add_directive(
                                    ElicitSlotDirective(
                                        slot_to_elicit=current_slot.name
                                    )).response

        return handler_input.response_builder.add_directive(
            DelegateDirective(
                updated_intent=current_intent
            )).response
Exemplo n.º 4
0
    def handle(self, handler_input):
        session_attr = handler_input.attributes_manager.session_attributes

        value = handler_input.request_envelope.request.intent.slots[
            'Solution'].value
        session_attr['intentname'] = "SolutionIntent"

        session_attr['numberSolutions'] += 1
        session_attr['solution'][session_attr['numberSolutions']] = value
        handler_input.attributes_manager.session_attributes = session_attr

        if handler_input.request_envelope.request.dialog_state != DialogState.COMPLETED:
            speech = 'I heard ' + str(value) + '. That is ' + str(
                session_attr['numberSolutions']
            ) + ' solutions so far. Do you have other solutions? If yes, then say "My solution is" or  else say no more solutions'
            reprompt = " I am interested in hearing any potential solutions. Say something that begins with my solution is. When you're done, say no more solutions"
            handler_input.attributes_manager.session_attributes = session_attr
            handler_input.response_builder.speak(speech).ask(reprompt)
            return handler_input.response_builder.response

        else:
            handler_input.attributes_manager.session_attributes = session_attr
            handler_input.response_builder.add_directive(
                DelegateDirective(updated_intent="SolutionEndIntent"))
            return handler_input.response_builder.response
Exemplo n.º 5
0
def setup_intent_handler(handler_input):
    session_attr = get_session_attr(handler_input, 'setup')

    if handler_input.request_envelope.request.dialog_state != DialogState.COMPLETED:
        return handler_input.response_builder.add_directive(
            DelegateDirective()).response

    filled_slots = handler_input.request_envelope.request.intent.slots
    slots = get_slot_values(filled_slots)

    settings = {'user': slots['user_name'], 'maker': slots['maker_name']}

    handler_input.attributes_manager.persistent_attributes = settings
    handler_input.attributes_manager.save_persistent_attributes()
    speech_text = "What kind of coffee would you like?"
    reprompt = 'What coffee do you want?'
    card_text = speech_text

    session_attr['user'] = slots['user_name']
    session_attr['maker'] = slots['maker_name']
    save_last_response(session_attr, speech_text, reprompt, card_text)
    handler_input.attributes_manager.session_attributes = session_attr

    handler_input.response_builder.speak(speech_text).ask(reprompt).set_card(
        SimpleCard(skillName, card_text))
    return handler_input.response_builder.response
 def handle(self, handler_input):
     logger.info('In YesMoreInfoIntentHandler')
     session_attr = handler_input.attributes_manager.session_attributes
     # coming from RandomCocktailIntent
     # changing the intent to AskForCocktail, because user wants to know
     # infos on a specific cocktail
     if session_attr['current_intent'] == 'RandomCocktailIntent':
         return handler_input.response_builder.add_directive(
             DelegateDirective(
                 updated_intent='AskForCocktail')).response
     # coming from FilterIntent, listing the cocktails for the response
     elif session_attr['current_intent'] == 'FilterIntent':
         drink_list = session_attr['filtered_drinks']
         if len(drink_list) < 4:
             speech = ', '.join(drink_list)
         else:
             # for the case that more than three drinks are found,
             # three random ones are chosen
             drink_samples = random.sample(drink_list, 3)
             speech = get_speech('DRINK_LIST').format(drink_samples[0],
                                                      drink_samples[1],
                                                      drink_samples[2]
                                                      )
             # safes response to be repeated by request
             session_attr['last_speech'] = speech
     handler_input.response_builder.speak(
         speech).set_should_end_session(False)
     return handler_input.response_builder.response
    def handle(self, handler_input):
        session_attr = handler_input.attributes_manager.session_attributes
        slots = handler_input.request_envelope.request.intent.slots
        pos = slots["Position"].value
        session_attr["Position"] = int(pos)

        return handler_input.response_builder.add_directive(
            DelegateDirective(updated_intent="Linechart")).response
Exemplo n.º 8
0
    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
Exemplo n.º 9
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        
        session_attr = handler_input.attributes_manager.session_attributes
        
        speech = 'No problem I will repeat the instance for you'
        intent = session_attr['intentname']

        handler_input.response_builder.add_directive(DelegateDirective(updated_intent = intent)).speak(speech)
        return handler_input.response_builder.response
Exemplo n.º 10
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        session_attr = handler_input.attributes_manager.session_attributes
        session_attr['intentname'] = "SolutionChoiceIntent"
        handler_input.attributes_manager.session_attributes = session_attr

        speech = 'We now go to the final step of making an action plan for your solution. What do you need to do? When will this start? Start by saying "My plan is"'
        reprompt = 'What is your action plan?';
        
        handler_input.response_builder.add_directive(DelegateDirective(updated_intent = "ActionPlanIntent")).speak(speech).ask(reprompt)
        return handler_input.response_builder.response
Exemplo n.º 11
0
    def handle(self, handler_input):
        session_attr = handler_input.attributes_manager.session_attributes
        session_attr['intentname'] = "ProsAndConsIntent"
        handler_input.attributes_manager.session_attributes = session_attr

        session_attr['statement'] = "0"
        handler_input.attributes_manager.session_attributes = session_attr
        
        if (int(session_attr["numberSolutions"]) == 1 or session_attr['i'] == 1):
            session_attr['statement'] = "1"
            value = session_attr['solution']["1"]
            session_attr['i'] += 1
            handler_input.attributes_manager.session_attributes = session_attr
            speech = "Great effort brainstorming solutions! Now let's move on. For each solution you mentioned, think about possible pros and cons. When you're ready, for your solution " + str(value) + ', first say the pros are and then say the cons are.  '
            reprompt = "Any pros and cons for " + str(value) + "?"
            handler_input.response_builder.speak(speech).ask(reprompt)
            return handler_input.response_builder.response
            
        elif ((int(session_attr["numberSolutions"]) > session_attr['i']) and (handler_input.request_envelope.request.dialog_state != DialogState.COMPLETED)):
            oldvalue = session_attr['solution'][str(session_attr['i']-1)]
            value = session_attr['solution'][str(session_attr['i'])]
            session_attr['proandcon'][oldvalue] = [handler_input.request_envelope.request.intent.slots['Pro'].value, handler_input.request_envelope.request.intent.slots['Con'].value]
            handler_input.attributes_manager.session_attributes = session_attr
            session_attr['i'] += 1
            speech = 'For your solution ' + str(value) + ', first say the pros are and then say the cons are.'
            reprompt = "Any pros and cons for " + str(value) + "?"
            session_attr['statement'] = "2"
            handler_input.attributes_manager.session_attributes = session_attr
            handler_input.response_builder.speak(speech).ask(reprompt)
            return handler_input.response_builder.response
            
        elif ((int(session_attr["numberSolutions"]) == session_attr['i']) and (handler_input.request_envelope.request.dialog_state != DialogState.COMPLETED)):
            oldvalue = session_attr['solution'][str(session_attr['i']-1)]
            value = session_attr['solution'][str(session_attr['i'])]
            session_attr['proandcon'][oldvalue] = [handler_input.request_envelope.request.intent.slots['Pro'].value, handler_input.request_envelope.request.intent.slots['Con'].value]
            handler_input.attributes_manager.session_attributes = session_attr
            speech = 'For your solution ' + str(value) + ', first say the pros are and then say the cons are.'
            reprompt = "Any pros and cons for " + str(value) + "?"
            session_attr['statement'] = "3"
            session_attr['i'] += 1
            handler_input.attributes_manager.session_attributes = session_attr
            handler_input.response_builder.speak(speech).ask(reprompt)
            return handler_input.response_builder.response   
            
        elif (((int(session_attr["numberSolutions"]) + 1) == session_attr['i']) and (handler_input.request_envelope.request.dialog_state != DialogState.COMPLETED)):
            oldvalue = session_attr['solution'][str(session_attr['i']-1)]
            session_attr['proandcon'][oldvalue] = [handler_input.request_envelope.request.intent.slots['Pro'].value, handler_input.request_envelope.request.intent.slots['Con'].value]
            handler_input.attributes_manager.session_attributes = session_attr
            speech = "You are done with the Pros and Cons. Kindly end this intent by saying 'no more pros and cons'"
            session_attr['statement'] = "4"
            handler_input.attributes_manager.session_attributes = session_attr
            handler_input.response_builder.add_directive(DelegateDirective(updated_intent = "ProsAndConsEndIntent"))
            return handler_input.response_builder.response
Exemplo n.º 12
0
 def handle(self, handler_input):
     # type: (HandlerInput) -> Response
     session_attr = handler_input.attributes_manager.session_attributes
     session_attr['intentname'] = "ActionPlanIntent"
     handler_input.attributes_manager.session_attributes = session_attr
     
     speech = ("Sound's like you have a plan. How confident do you feel on a scale from 1-10, where 1 is not confident at all, and 10 is very confident that "
         ' you will be able to carry out the plan to solve your problem?')
     reprompt = 'On a scale from 1-10, how confident are you that you can carry out your plan?'
     
     handler_input.response_builder.add_directive(DelegateDirective(updated_intent = 'ConfidenceIntent')).speak(speech).ask(reprompt)
     return handler_input.response_builder.response
Exemplo n.º 13
0
def yes_handler(handler_input: HandlerInput):
    """handler for Yes Intent if only user is not registered and was asked if they want to register"""
    attr = handler_input.attributes_manager.session_attributes
    attr["user_name"] = handler_input.request_envelope.session.user.user_id.split(".")[
        -1
    ]
    attr[
        "user_access_token"
    ] = handler_input.request_envelope.context.system.api_access_token
    attr["user_new"] = False
    attr["transaction_state"] = "STARTED"

    return handler_input.response_builder.add_directive(
        DelegateDirective(updated_intent=intent_vars.REGISTER_USER)
    ).response
Exemplo n.º 14
0
    def handle(self, handler_input):
        currentIntent = handler_input.request_envelope.request.intent

        result = disambiguateSlot(getSlotValues(currentIntent.slots))

        if result:
            handler_input.response_builder.speak(result["prompt"]).ask(
                result["prompt"]).add_directive(
                    ElicitSlotDirective(
                        slot_to_elicit=result["slotName"])).response
        else:
            handler_input.response_builder.add_directive(
                DelegateDirective(updated_intent=currentIntent)).response

        return handler_input.response_builder.response
Exemplo n.º 15
0
    def handle(self, handler_input):
        
        session_attr = handler_input.attributes_manager.session_attributes
        session_attr['intentname'] = "SolutionEndIntent"
        handler_input.attributes_manager.session_attributes = session_attr
        
        speech = ("Great effort brainstorming solutions! Now let's move on. For each solution you mentioned, think about all the advantages or pros of that solution. "
            'Also, consider all of the possible disadvantages or "cons" of that solution.')
        reprompt = 'I have heard your solutions. Do you know of any pros or cons?'
        
        session_attr = handler_input.attributes_manager.session_attributes
        session_attr['intentname'] = "SolutionEndIntent"
        handler_input.attributes_manager.session_attributes = session_attr

        handler_input.response_builder.add_directive(DelegateDirective(updated_intent = 'ProsAndConsIntent'))
        return handler_input.response_builder.response
Exemplo n.º 16
0
    def handle(self, handler_input):
        slots = handler_input.request_envelope.request.intent.slots
        if 'ingredient' in slots.keys() and slots['ingredient'].value == None:
            prompt = "Ok, what ingredient would you like to add?"
            return handler_input.response_builder.speak(prompt).ask(
                prompt).add_directive(
                    ElicitSlotDirective(slot_to_elicit='ingredient')).response
        elif 'amount' in slots.keys() and slots['amount'].value == None:
            prompt = "Ok, what amount should I add?"
            return handler_input.response_builder.speak(prompt).ask(
                prompt).add_directive(
                    ElicitSlotDirective(slot_to_elicit='amount')).response

        return handler_input.response_builder.add_directive(
            DelegateDirective(updated_intent=handler_input.request_envelope.
                              request.intent)).response
Exemplo n.º 17
0
    def handle(self, handler_input):
        
        session_attr = handler_input.attributes_manager.session_attributes
        session_attr['intentname'] = "ProblemIntent"
        handler_input.attributes_manager.session_attributes = session_attr
        
        speech = ('Thank you for sharing with me. You have identified a problem and set a goal. Good so far. '
            'Next, I would like you to brainstorm some possible solutions to your problem. This may take a few minutes. Try to '
            "be as creative as possible. Don't limit yourself in any way. When you are ready, tell me your solution, by saying "
            "my solution is. When you're done, no more solutions")

        reprompt = "I am interested in hearing any potential solutions. Say something that begins with my solution is. When you're done, say no more solutions"
        
        handler_input.response_builder.add_directive(DelegateDirective(updated_intent = 'SolutionIntent')).speak(speech).ask(reprompt)
        #handler_input.response_builder.speak(speech).ask(reprompt)
        return handler_input.response_builder.response
Exemplo n.º 18
0
    def handle(self, handler_input):
        session_attr = handler_input.attributes_manager.session_attributes
        solutionText = ""
        session_attr['intentname'] = "ProsAndConsEndIntent"
        handler_input.attributes_manager.session_attributes = session_attr
        
        i = 1
        
        while i <=  int(session_attr["numberSolutions"]) :
            solutionText = solutionText + str(session_attr["solution"][str(i)]) + ","
            i += 1

        speech = 'Thank you for being open about the pros and cons of your solutions. Now I would like you to choose a solution to try for next week. ' + 'Think about which solution is most feasible. Which has the best chance of achieving your goal. ' +'The solutions you have mentioned are ' + str(solutionText) + ' and you can choose one.' + "Start by saying I choose"
        reprompt = "What solution would you like to try?"
        
        handler_input.response_builder.speak(speech).ask(reprompt).add_directive(DelegateDirective(updated_intent = "SolutionChoiceIntent"))
        return handler_input.response_builder.response
Exemplo n.º 19
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        
        slots = handler_input.request_envelope.request.intent.slots
        user = slots["UserName"].value
        
        speak_output = (' Hello {user}. Welcome to your first counseling session.<break time="1s"/>'
                        'Before we get started with our session, I need you to complete your PHQ-9 and GAD-7 surveys. '
                        'I texted you the link earlier today. Please complete them now, then restart our session.<break time="1s"/> '
                        'If you have completed the survey then say Survey Completed'
                        ).format(user = user)

        return (
            handler_input.response_builder
                .speak(speak_output)
                .add_directive(DelegateDirective(updated_intent = 'S1M1UthreeaIntent'))
                # .ask("add a reprompt if you want to keep the session open for the user to respond")
                .response)
Exemplo n.º 20
0
def ready_game_handler(handler_input):
    # handles the start of the game setting up how many rounds
    # current_intent gets details about returned intent for checking use .name, .slots etc
    current_intent = handler_input.request_envelope.request.intent
    game_session_attr = handler_input.attributes_manager.session_attributes

    logger.info("In ReadyGameHandler")
    if (
        current_intent.slots["game_length"].name in required_slots
        and current_intent.slots["game_length"].value not in rounds_allowed
    ):

        return (
            handler_input.response_builder.speak(
                "ok how big a deck of cards should I use? "
                "Five is a short game, Fifteen is X minutes, Twenty-Five "
                "is the about XX minutes but gives the most accurate score "
            )
            .ask("five ten or fifteen")
            .add_directive(
                ElicitSlotDirective(
                    slot_to_elicit="game_length",
                    updated_intent=Intent(
                        name="ReadyGame",
                        confirmation_status=IntentConfirmationStatus.NONE,
                        slots={
                            "game_length": Slot(
                                name="game_length",
                                confirmation_status=SlotConfirmationStatus.NONE,
                            )
                        },
                    ),
                )
            )
            .response
        )
    # game_session_attr['DECK_SIZE'] = current_intent.slots["game_length"].value
    # game_session_attr['GAME_RUNNING'] = 1
    return handler_input.response_builder.add_directive(
        DelegateDirective(updated_intent=current_intent)
    ).response
Exemplo n.º 21
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In InProgressPetMatchIntent")
        current_intent = handler_input.request_envelope.request.intent
        prompt = ""

        for slot_name, current_slot in current_intent.slots.items():
            if (current_slot.confirmation_status !=
                    SlotConfirmationStatus.CONFIRMED
                    and current_slot.resolutions
                    and current_slot.resolutions.resolutions_per_authority[0]):
                if current_slot.resolutions.resolutions_per_authority[
                        0].status.code == StatusCode.ER_SUCCESS_MATCH:
                    if len(current_slot.resolutions.
                           resolutions_per_authority[0].values) > 1:
                        prompt = "Which would you like "

                        values = " or ".join([
                            e.value.name for e in current_slot.resolutions.
                            resolutions_per_authority[0].values
                        ])
                        prompt += values + " ?"
                        return handler_input.response_builder.speak(
                            prompt).ask(prompt).add_directive(
                                ElicitSlotDirective(
                                    slot_to_elicit=current_slot.name)).response
                elif current_slot.resolutions.resolutions_per_authority[
                        0].status.code == StatusCode.ER_SUCCESS_NO_MATCH:
                    if current_slot.name in required_slots:
                        prompt = "Do you want {} to be low, medium, or high?".format(
                            current_slot.name)

                        return handler_input.response_builder.speak(
                            prompt).ask(prompt).add_directive(
                                ElicitSlotDirective(
                                    slot_to_elicit=current_slot.name)).response

        return handler_input.response_builder.add_directive(
            DelegateDirective(updated_intent=current_intent)).response
Exemplo n.º 22
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In HelpIntentHandler")

        # Create a GravityIntent object so we can get back to the GravityIntentHandler
        gravIntent = Intent(name="GravityIntent")

        # extract our saved values from the S3 repository
        savedAttrs = handler_input.attributes_manager.persistent_attributes
        logger.info(f"In HelpIntentHandler: savedAttrs is {savedAttrs}. ")

        # Get any slot values from the user
        slots = handler_input.request_envelope.request.intent.slots
        logger.info(f"In HelpIntentHandler: slots={slots} ")

        handler_input.response_builder.speak(data.HELP_MESSAGE).ask(
            data.HELP_MESSAGE).set_card(
                SimpleCard(data.SKILL_TITLE, data.CARD_HELP))

        handler_input.response_builder.add_directive(
            DelegateDirective(updated_intent=gravIntent))

        return handler_input.response_builder.response
Exemplo n.º 23
0
def in_progress_pet_match_intent(handler_input):
    # type: (HandlerInput) -> Response
    logger.info('in InProgressPetMatchIntent')
    current_intent = handler_input.request_envelope.request.intent
    prompt = ''

    for slot_name, current_slot in six.iteritems(current_intent.slots):
        if slot_name not in ['article', 'at_the', 'I want']:
            if current_slot.confirmation_status != SlotConfirmationStatus.CONFIRMED \
                    and current_slot.resolutions \
                    and current_slot.resolutions.resolutions_per_authority[0]:
                if current_slot.resolutions.resolutions_per_authority[
                        0].status_code == StatusCode.ER_SUCCESS_MATCH:
                    if len(current_slot.resolutions.
                           resolutions_per_authority[0].values) > 1:
                        prompt = 'Which would you like '

                        values = ' or '.join([
                            e.value.name for e in current_slot.resolutions.
                            resolutions_per_authority[0].values
                        ])
                        prompt += values + ' ?'
                        return handler_input.response_builder.speak(
                            prompt).ask(prompt).add_directive(
                                ElicitSlotDirective(
                                    slot_to_elicit=current_slot.name)).response
                elif current_slot.resolutions.resolutions_per_authority[
                        0].status_code == StatusCode.ER_SUCCESS_NO_MATCH:
                    if current_slot.name in required_slots:
                        prompt = f'What {current_slot.name} are you looking for?'
                        return handler_input.response_builder.speak(
                            prompt).ask(prompt).add_directive(
                                ElicitSlotDirective(
                                    slot_to_elicit=current_slot.name)).response
    return handler_input.response_builder.add_directive(
        DelegateDirective(updated_intent=current_intent)).response
Exemplo n.º 24
0
    def handle(self, handler_input):
        session_attr = handler_input.attributes_manager.session_attributes
        session_attr['intentname'] = "ProsAndConsIntent"
        handler_input.attributes_manager.session_attributes = session_attr

        session_attr['statement'] = "0"
        handler_input.attributes_manager.session_attributes = session_attr

        if ((int(session_attr["numberSolutions"]) == 1
             or session_attr['i'] == 1)
                and (handler_input.request_envelope.request.dialog_state !=
                     DialogState.COMPLETED)):
            session_attr['statement'] = "1"
            value = session_attr['solution']["1"]
            session_attr['i'] += 1
            handler_input.attributes_manager.session_attributes = session_attr
            speech = 'For your solution ' + str(
                value
            ) + ', say a pro and a con for your solution. Say "a pro is" or "a con is" or "no more pros and cons" to end'
            reprompt = "Any pros and cons for " + str(value) + "?"
            handler_input.response_builder.speak(speech).ask(reprompt)
            return handler_input.response_builder.response

        elif ((int(session_attr["numberSolutions"]) > session_attr['i'])
              and (handler_input.request_envelope.request.dialog_state !=
                   DialogState.COMPLETED)):
            oldvalue = session_attr['solution'][str(session_attr['i'] - 1)]
            value = session_attr['solution'][str(session_attr['i'])]
            session_attr['proandcon'][oldvalue] = [
                handler_input.request_envelope.request.intent.slots['Pro'].
                value, handler_input.request_envelope.request.intent.
                slots['Con'].value
            ]
            handler_input.attributes_manager.session_attributes = session_attr
            session_attr['i'] += 1
            speech = 'For your solution ' + str(
                value
            ) + ', say a pro and a con for your solution. Say "a pro is" or "a con is" or "no more pros and cons" to end'
            reprompt = "Any pros and cons for " + str(value) + "?"
            session_attr['statement'] = "2"
            handler_input.attributes_manager.session_attributes = session_attr
            handler_input.response_builder.speak(speech).ask(reprompt)
            return handler_input.response_builder.response

        elif ((int(session_attr["numberSolutions"]) == session_attr['i'])
              and (handler_input.request_envelope.request.dialog_state !=
                   DialogState.COMPLETED)):
            oldvalue = session_attr['solution'][str(session_attr['i'] - 1)]
            value = session_attr['solution'][str(session_attr['i'])]
            session_attr['proandcon'][oldvalue] = [
                handler_input.request_envelope.request.intent.slots['Pro'].
                value, handler_input.request_envelope.request.intent.
                slots['Con'].value
            ]
            handler_input.attributes_manager.session_attributes = session_attr
            speech = 'For your solution ' + str(
                value
            ) + ', say a pro and a con for your solution. Say "a pro is" or "a con is" or "no more pros and cons" to end'
            reprompt = "Any pros and cons for " + str(value) + "?"
            session_attr['statement'] = "3"
            session_attr['i'] += 1
            handler_input.attributes_manager.session_attributes = session_attr
            handler_input.response_builder.speak(speech).ask(reprompt)
            return handler_input.response_builder.response

        elif (((int(session_attr["numberSolutions"]) + 1) == session_attr['i'])
              and (handler_input.request_envelope.request.dialog_state !=
                   DialogState.COMPLETED)):
            oldvalue = session_attr['solution'][str(session_attr['i'] - 1)]
            session_attr['proandcon'][oldvalue] = [
                handler_input.request_envelope.request.intent.slots['Pro'].
                value, handler_input.request_envelope.request.intent.
                slots['Con'].value
            ]
            handler_input.attributes_manager.session_attributes = session_attr
            speech = "You are done with the Pros and Cons. Kindly end this intent by saying 'no more pros and cons'"
            session_attr['statement'] = "4"
            handler_input.attributes_manager.session_attributes = session_attr
            handler_input.response_builder.add_directive(
                DelegateDirective(updated_intent="ProsAndConsEndIntent"))
            return handler_input.response_builder.response
Exemplo n.º 25
0
    def handle(self, handler_input):
        """Handler for Processing a saved calibration value"""
        # save our current Intent so we can get back here if we have to
        calIntent = handler_input.request_envelope.request.intent
        logger.info(f"In CalibrateIntentHandler: calIntent is {calIntent}. ")

        # Create a GravityIntent object so we can get back to the GravityIntentHandler
        gravIntent = Intent(name="GravityIntent")

        # extract our saved values from the S3 repository
        savedAttrs = handler_input.attributes_manager.persistent_attributes
        logger.info(f"In CalibrateIntentHandler: savedAttrs is {savedAttrs}.")

        defaultAsked = savedAttrs.get('defaultAsked', False)

        # Get any slot values from the user
        slots = handler_input.request_envelope.request.intent.slots
        logger.info(f"In CalibrateIntentHandler: slots={slots}")

        # if we have a slot, get its value
        if slots:
            calTemp = slots["caliDefault"].value
        else:
            calTemp = None

        # if we already asked the user, then the reply is in the caliDefault slot
        # it could be a number, or something else
        if defaultAsked:
            # See if it is a number
            try:
                calTempFloat = float(calTemp)
                # Yes, we have a number. Return it to GravityIntent as the new calibration temperature
                savedAttrs[
                    'calibration'] = calTemp  # return the new calibration in GravityIntent's slot
                gravSlots = {}
                for name, value in savedAttrs.items():
                    gravSlot = Slot(name=name, value=value)
                    if name == "gravity" or name == "temperature" or name == "calibration":
                        gravSlots[gravSlot.name] = {
                            'confirmation_status':
                            gravSlot.confirmation_status,
                            'name': gravSlot.name,
                            'resolutions': gravSlot.resolutions,
                            'value': gravSlot.value
                        }
                gravIntent.slots = gravSlots
                logger.info(
                    f"In CalibrateIntentHandler: Returning new calibration to {gravIntent}. "
                )
                handler_input.response_builder.add_directive(
                    DelegateDirective(updated_intent=gravIntent))
                return handler_input.response_builder.response
            except:
                # This intent's slot was not a number. If it is some form of agreement, pass the save calibration back to GravityIntent
                calResolutions = slots["caliDefault"].resolutions
                userResponse = calResolutions.resolutions_per_authority[
                    0].status.code
                # Did the user say something we recognize as an affirmative?
                if userResponse == StatusCode.ER_SUCCESS_MATCH:
                    gravSlots = {}
                    for name, value in savedAttrs.items():
                        gravSlot = Slot(name=name, value=value)
                        if name == "gravity" or name == "temperature" or name == "calibration":
                            gravSlots[gravSlot.name] = {
                                'confirmation_status':
                                gravSlot.confirmation_status,
                                'name': gravSlot.name,
                                'resolutions': gravSlot.resolutions,
                                'value': gravSlot.value
                            }
                    gravIntent.slots = gravSlots
                    logger.info(
                        f"In CalibrateIntentHandler: Using default calibration to {gravIntent}."
                    )
                    handler_input.response_builder.add_directive(
                        DelegateDirective(updated_intent=gravIntent))
                    return handler_input.response_builder.response
                else:
                    # Otherwise, try to get something we understand
                    speech = f"Sorry, you said {calTemp}. Please reply with a new calibration temperature or reply 'yes' to use the default."
                    reprompt = "Please say 'yes' or reply with a new calibration temperature."
                    handler_input.response_builder.speak(speech).ask(
                        reprompt).set_should_end_session(False).set_card(
                            SimpleCard(data.SKILL_TITLE, reprompt))
                    handler_input.response_builder.add_directive(
                        ElicitSlotDirective(slot_to_elicit="caliDefault",
                                            updated_intent=calIntent))
                    return handler_input.response_builder.response

        # At this point, we haven't ask the user anything
        # Set the "asked" flag
        savedAttrs['defaultAsked'] = True
        handler_input.attributes_manager.persistent_attributes = savedAttrs
        handler_input.attributes_manager.save_persistent_attributes()

        # Ask the user to confirm the default or provide a new calibration temperature
        speech = f"You have a default calibration temperature of {calTemp}. Do you want to use the default?"
        reprompt = "Please say 'yes' or reply with a new calibration temperature."
        handler_input.response_builder.speak(speech).ask(
            reprompt).set_should_end_session(False).set_card(
                SimpleCard(data.SKILL_TITLE, reprompt))
        handler_input.response_builder.add_directive(
            ElicitSlotDirective(slot_to_elicit="caliDefault",
                                updated_intent=calIntent))
        return handler_input.response_builder.response
Exemplo n.º 26
0
    def handle(self, handler_input):
        """Handler for Processing the gravity correction"""
        # Create an Intent object for GravityIntent
        gravIntent = handler_input.request_envelope.request.intent
        logger.info(f"In GravityIntentHandler: gravIntent is {gravIntent}. ")

        # Obtain the request object
        request = handler_input.request_envelope.request

        # Get any slot values from the user
        slots = handler_input.request_envelope.request.intent.slots
        logger.info(f"In GravityIntentHandler: slots={slots}")

        # extract slot values
        gravity = slots["gravity"].value
        temp = slots["temperature"].value
        calTemp = slots["calibration"].value
        logger.info(
            f"In GravityIntentHandler: gravity is {gravity} and temp {temp}")

        # extract any saved values from the S3 repository
        savedAttrs = handler_input.attributes_manager.persistent_attributes
        defaultAsked = savedAttrs.get('defaultAsked', False)

        # In an effort to vary the user experience, keep track of the number of times we have asked for a slot
        # so that we can escalate our responses
        gravityAsked = savedAttrs.get('gravityAsked', 0)
        tempAsked = savedAttrs.get('tempAsked', 0)
        caliAsked = savedAttrs.get('caliAsked', 0)

        logger.info(
            f"In GravityIntentHandler: gravityAsked is {gravityAsked}, tempAsked {tempAsked}, and caliAsked {caliAsked}"
        )

        # See if we have a default calibration temperature
        savedCalibration = savedAttrs.get('calibration', 0)
        if savedCalibration == 0:
            calDefault = False
        else:
            calDefault = True

        try:
            gravityFloat = float(gravity)
        except:
            gravityAsked += 1
            speech = data.GRAVITY_MESSAGES[gravityAsked].format(gravity)
            reprompt = "What was the gravity measure again? "

            if gravityAsked >= 3:
                gravityAsked = 0

            savedAttrs['gravityAsked'] = gravityAsked
            handler_input.attributes_manager.persistent_attributes = savedAttrs
            handler_input.attributes_manager.save_persistent_attributes()

            handler_input.response_builder.speak(speech).ask(reprompt)
            handler_input.response_builder.add_directive(
                ElicitSlotDirective(slot_to_elicit="gravity",
                                    updated_intent=gravIntent))
            handler_input.response_builder.set_should_end_session(False)
            return handler_input.response_builder.response

        try:
            tempFloat = float(temp)
        except:
            tempAsked += 1
            if tempAsked < 3:
                speech = data.TEMPERATURE_MESSAGES[tempAsked].format(
                    util.saySpecificGravity(gravity))
            else:
                speech = data.TEMPERATURE_MESSAGES[tempAsked].format(temp)
            reprompt = "at what temperature was your gravity measurement taken?"

            if tempAsked >= 3:
                tempAsked = 0
            savedAttrs['tempAsked'] = tempAsked
            handler_input.attributes_manager.persistent_attributes = savedAttrs
            handler_input.attributes_manager.save_persistent_attributes()

            handler_input.response_builder.speak(speech).ask(
                reprompt).set_should_end_session(False)
            handler_input.response_builder.add_directive(
                ElicitSlotDirective(slot_to_elicit="temperature",
                                    updated_intent=gravIntent))
            return handler_input.response_builder.response

        # Try to use a specified calibration temperature.
        # if there is none, try to use a saved calibration temperature.
        # if that fails, ask the user for a calibration temperature
        logger.info(
            f"in GravityIntentHandler: calTemp is {calTemp} and calDefault is {calDefault}"
        )

        # If we have not yet asked about the calibration temperature, delegate control to the Calibrate Intent
        if not defaultAsked and calDefault:
            # Save the responses we have to the S3 repository, so the Calibration Intent can return them back to us
            savedAttrs['gravity'] = gravity
            savedAttrs['temperature'] = temp
            savedAttrs['defaultAsked'] = False
            handler_input.attributes_manager.persistent_attributes = savedAttrs
            handler_input.attributes_manager.save_persistent_attributes()

            # build an Intent object for CalibrateIntent
            calIntent = Intent(name="CalibrateIntent")
            calSlots = {}
            calSlot = Slot(name="caliDefault", value=savedCalibration)
            calSlots[calSlot.name] = {
                'confirmation_status': calSlot.confirmation_status,
                'name': calSlot.name,
                'resolutions': calSlot.resolutions,
                'value': calSlot.value
            }
            calIntent.slots = calSlots

            # Delegate CalibrateIntent
            logger.info(
                f"in GravityIntentHandler: about to delegate CalibrateIntent. Intent is {calIntent} "
            )
            handler_input.response_builder.add_directive(
                DelegateDirective(updated_intent=calIntent))
            return handler_input.response_builder.response
        # end of "if not defaultAsked:"

        try:
            calTempFloat = float(calTemp)
        except:
            caliAsked += 1
            speech = data.CALIBRATE_MESSAGES[caliAsked].format(
                util.saySpecificGravity(gravity), temp)
            reprompt = "You can say something like, '60'"

            if caliAsked >= 3:
                caliAsked = 0
            savedAttrs['caliAsked'] = caliAsked
            handler_input.attributes_manager.persistent_attributes = savedAttrs
            handler_input.attributes_manager.save_persistent_attributes()

            handler_input.response_builder.speak(speech).ask(
                reprompt).set_should_end_session(False)

            handler_input.response_builder.add_directive(
                ElicitSlotDirective(slot_to_elicit="calibration",
                                    updated_intent=gravIntent))
            return handler_input.response_builder.response

        if util.validateSG(gravityFloat) == 0:
            speech = data.GRAVITY_MESSAGES[3].format(gravity)
            reprompt = "Please enter a valid specific gravity. "
            handler_input.response_builder.speak(speech).ask(
                reprompt).set_should_end_session(False)
            handler_input.response_builder.add_directive(
                ElicitSlotDirective(slot_to_elicit="gravity",
                                    updated_intent=gravIntent))
            return handler_input.response_builder.response

        tempFloat = util.validateTemp(tempFloat)
        calTempFloat = util.validateTemp(calTempFloat)

        if tempFloat == 0:
            speech = data.TEMPERATURE_MESSAGES[3].format(temp)
            reprompt = "Please enter a valid temperature. "
            handler_input.response_builder.speak(speech).ask(
                reprompt).set_should_end_session(False)
            handler_input.response_builder.add_directive(
                ElicitSlotDirective(slot_to_elicit="temperature",
                                    updated_intent=gravIntent))
            return handler_input.response_builder.response

        if calTempFloat == 0:
            speech = data.CALIBRATE_MESSAGES[3].format(calTemp)
            reprompt = "Please enter a valid calibration temperature. "
            handler_input.response_builder.speak(speech).ask(
                reprompt).set_should_end_session(False)
            handler_input.response_builder.add_directive(
                ElicitSlotDirective(slot_to_elicit="calibration",
                                    updated_intent=gravIntent))
            return handler_input.response_builder.response

        # We have all the validated values, save them in the S3 repository
        savedAttrs['gravity'] = gravity
        savedAttrs['temperature'] = temp
        savedAttrs['calibration'] = calTemp
        savedAttrs['defaultAsked'] = False
        savedAttrs['gravityAsked'] = 0
        savedAttrs['tempAsked'] = 0
        savedAttrs['caliAsked'] = 0
        handler_input.attributes_manager.persistent_attributes = savedAttrs
        handler_input.attributes_manager.save_persistent_attributes()
        logger.info("In GravityIntentHandler: Saved response in S3 repository")

        # Calculate the corrected gravity
        numeratorValue = 1.00130346 - (0.000134722124 * tempFloat) + (
            0.00000204052596 * tempFloat**2) - (0.00000000232820948 *
                                                tempFloat**3)
        denominatorValue = 1.00130346 - (0.000134722124 * calTempFloat) + (
            0.00000204052596 * calTempFloat**2) - (0.00000000232820948 *
                                                   calTempFloat**3)

        corrGravity = gravityFloat * (numeratorValue / denominatorValue)

        logger.info(
            f"In GravityIntentHandler: corrected gravity is {corrGravity}. ")

        speech = f"your corrected gravity is {util.saySpecificGravity(round(corrGravity))}. "
        speech += data.EXIT_SKILL_MESSAGE
        cardText = f"your corrected gravity is {int(round(corrGravity))*0.001}."

        handler_input.response_builder.speak(speech).set_should_end_session(
            True).set_card(SimpleCard(data.SKILL_TITLE, cardText))

        return handler_input.response_builder.response
Exemplo n.º 27
0
 def handle(self, handler_input):
     print("In PriceIntent – valid & uncompleted")
     # current_intent = handler_input.request_envelope.request.intent
     return handler_input.response_builder.add_directive(
         DelegateDirective()).response
Exemplo n.º 28
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        # begin workaround why dialogState not being set to complete
        cur_state = get_statex(handler_input, "fever")
        current_intent = handler_input.request_envelope.request.intent
        cur_intent_name = current_intent.name
        print("DEBUG CURRENT STATE   handler ", cur_state, cur_intent_name)

        if is_current_statex(handler_input, "fever", 'fever_completedx'):
            print("DEBUG fever 165  COMPLETING")
            handler_input.request_envelope.request.dialog_state = DialogState.COMPLETED  # try again
            completed_resp = do_fever_complete(handler_input)
            return completed_resp
        else:
            print("DEBUG2 InProgress_fever_Intent NOT COMPLETING")

        if handler_input.request_envelope.request.dialog_state == DialogState.STARTED:

            print(" DEEBUG InProgress fever  RESTORE")

            #tbd do a better job of recovery
            restore_slots(handler_input, cur_intent_name)
            if not (get_statex(handler_input, cur_intent_name)):
                set_statex(handler_input, cur_intent_name, "fever_beginx")

        #else:
        # this save is a bit aggressive after after every user responds

        #save_slots(handler_input,cur_intent_name) # dialog not completed
        prompt = ""
        # go through each of the slots
        for statey in fever_state_to_slots:
            for slot_name in fever_state_to_slots[statey]:
                # dont know why we didnt have a state, Once state is filled a different logic may arise
                # take the first one that hasnt been filled
                current_slot = current_intent.slots[slot_name]  #slot object
                if (current_slot.confirmation_status !=
                        SlotConfirmationStatus.CONFIRMED
                        and current_slot.resolutions and
                        current_slot.resolutions.resolutions_per_authority[0]):

                    print(
                        " fever+status_code ", slot_name, current_slot.
                        resolutions.resolutions_per_authority[0].status.code)
                    # deal with equivalents, ask user to fill in one particular equivalent
                    if current_slot.resolutions.resolutions_per_authority[
                            0].status.code == StatusCode.ER_SUCCESS_MATCH:
                        if len(current_slot.resolutions.
                               resolutions_per_authority[0].values) > 1:
                            print("Setting state", statey, "  TO GET SLOT: ",
                                  slot_name)
                            set_statex(handler_input, cur_intent_name, statey)
                            prompt = "Could you clarify which of these you meant ?  "
                            values = " or ".join([
                                e.value.name for e in current_slot.resolutions.
                                resolutions_per_authority[0].values
                            ])
                            prompt += values + " ?"
                            save_slots(handler_input, cur_intent_name)
                            return handler_input.response_builder.speak(
                                prompt).ask(prompt).add_directive(
                                    ElicitSlotDirective(
                                        updated_intent=current_intent,
                                        slot_to_elicit=current_slot.name
                                    )  # may have been restored
                                ).response
                    # otherwise ask user for the slot itself
                    elif current_slot.resolutions.resolutions_per_authority[
                            0].status.code == StatusCode.ER_SUCCESS_NO_MATCH:
                        if current_slot.name in required_slots:
                            # dont understand this why we have to prompt if we are elicitung
                            print("elif Setting state", statey,
                                  "  TO GET SLOT: ", slot_name)
                            set_statex(handler_input, cur_intent_name, statey)

                            prompt = "Could we talk about Blood Pressure  ?"
                            save_slots(handler_input, cur_intent_name)
                            return handler_input.response_builder.speak(
                                prompt).ask(prompt).add_directive(
                                    ElicitSlotDirective(
                                        updated_intent=current_intent,
                                        slot_to_elicit=current_slot.name)
                                ).response
        #In case of no synonyms were reach here
        save_slots(handler_input, cur_intent_name)
        print("DEBUG delegate fever")
        return handler_input.response_builder.add_directive(
            DelegateDirective(updated_intent=current_intent)).response
Exemplo n.º 29
0
 def handle(self, handler_input):
     intent = Intent(name="AMAZON.StopIntent")
     handler_input.response_builder.add_directive(DelegateDirective(updated_intent=intent))
     return handler_input.response_builder.response
    def handle(self, handler_input):
        data = handler_input.attributes_manager.request_attributes["_"]
        session_attr = handler_input.attributes_manager.session_attributes
        skill_locale = handler_input.request_envelope.request.locale
        user_id = handler_input.request_envelope.context.system.user.user_id
        commons = SearchIntent()

        user_id = str(user_id)
        try:
            intent = session_attr["intent"]
        except:
            intent = ""

        if (intent == "SearchIntent") or (intent == "Alternate_1_reserve") or (
                intent == "Alternate_2_reserve") or (intent
                                                     == "Alternate_3_reserve"):
            logger.info("Yes intent reserve")
            logger.info(intent)
            handler_input.response_builder.set_should_end_session(False)
            return handler_input.response_builder.add_directive(
                DelegateDirective(updated_intent="ReserveRoom")).response

        elif intent == "FindRoomWithDate":
            handler_input.response_builder.set_should_end_session(False)
            return handler_input.response_builder.add_directive(
                DelegateDirective(updated_intent="FindRoomWithDate")).response

        elif intent == "Alternate_1_search":
            try:
                response_2 = session_attr["response_2"]
                result_2 = session_attr["result_2"]
                response_2 = response_2 + ' ' + commons.reserve_alternate(
                    data, handler_input, result_2, user_id, "Alternate_2")
                handler_input.response_builder.set_should_end_session(False)
                logger.info("Alternate_1_search_response_2")
                return handler_input.response_builder.speak(
                    response_2).response
            except:
                try:
                    response_3 = session_attr["response_3"]
                    result_3 = session_attr["result_3"]
                    response_3 = response_3 + ' ' + commons.reserve_alternate(
                        data, handler_input, result_3, user_id, "Alternate_3")
                    handler_input.response_builder.set_should_end_session(
                        False)
                    logger.info("Alternate_1_search_response_3")
                    return handler_input.response_builder.speak(
                        response_3).response
                except:
                    speech = data['NO_MORE_ALTERNATE_MSG'] + ' ' + data[
                        'NEW_SEARCH']
                    handler_input.response_builder.set_should_end_session(True)
                    logger.info("Alternate_1_search_exception")
                    return handler_input.response_builder.speak(
                        speech).response

        elif intent == "Alternate_2_search":
            try:
                response_3 = session_attr["response_3"]
                result_3 = session_attr["result_3"]
                response_3 = response_3 + ' ' + commons.reserve_alternate(
                    data, handler_input, result_3, user_id, "Alternate_3")
                handler_input.response_builder.set_should_end_session(False)
                logger.info("Alternate_2_search_response_3")
                return handler_input.response_builder.speak(
                    response_3).response
            except:
                speech = data["NO_MORE_ALTERNATE_MSG"] + ' ' + data[
                    'NEW_SEARCH']
                handler_input.response_builder.set_should_end_session(True)
                logger.info("Alternate_2_search_exception")
                return handler_input.response_builder.speak(speech).response

        elif intent == "Alternate_3_search":
            speech = data["NO_MORE_ALTERNATE_MSG"] + ' ' + data['NEW_SEARCH']
            handler_input.response_builder.set_should_end_session(True)
            logger.info("Alternate_3_search_exception")
            return handler_input.response_builder.speak(speech).response

        elif intent == "FindRoomWithDate":
            handler_input.response_builder.set_should_end_session(False)
            return handler_input.response_builder.add_directive(
                DelegateDirective(updated_intent="FindRoomWithDate")).response

        elif intent == "SearchIntentAlternative":
            try:
                response_1 = session_attr["response_1"]
                result_1 = session_attr["result_1"]
                response_1 = response_1 + ' ' + commons.reserve_alternate(
                    data, handler_input, result_1, user_id, "Alternate_1")
                handler_input.response_builder.set_should_end_session(False)
                logger.info("SearchIntentAlternative_response_1")
                return handler_input.response_builder.speak(
                    response_1).response
            except:
                try:
                    response_2 = session_attr["response_2"]
                    result_2 = session_attr["result_2"]
                    response_2 = response_2 + ' ' + commons.reserve_alternate(
                        data, handler_input, result_2, user_id, "Alternate_2")
                    handler_input.response_builder.set_should_end_session(
                        False)
                    logger.info("SearchIntentAlternative_response_2")
                    return handler_input.response_builder.speak(
                        response_2).response
                except:
                    try:
                        response_3 = session_attr["response_3"]
                        result_3 = session_attr["result_3"]
                        response_3 = response_3 + ' ' + commons.reserve_alternate(
                            data, handler_input, result_3, user_id,
                            "Alternate_3")
                        handler_input.response_builder.set_should_end_session(
                            False)
                        logger.info("SearchIntentAlternative_response_3")
                        return handler_input.response_builder.speak(
                            response_3).response
                    except:
                        speech = data["NO_MORE_ALTERNATE_MSG"]
                        handler_input.response_builder.set_should_end_session(
                            True)
                        logger.info("SearchIntentAlternative_exception")
                        return handler_input.response_builder.speak(
                            speech).response

        elif intent == "RemoveReservation":
            db = ReserveRooms()
            confirmation = db.remove_reservation(user_id)
            if not confirmation:
                speech = data["NO_RESERVATION"]
            elif confirmation == 'error':
                speech = data["ERROR_RESERVATION_CANCEL"]
            else:
                speech = data["CANCEL_RESERVATION"]
            handler_input.response_builder.set_should_end_session(True)
            return handler_input.response_builder.speak(speech).response

        else:
            logger.info("Yes intent goodbye")
            logger.info(intent)
            speech = data["GOODBYE_MSG"]
            handler_input.response_builder.set_should_end_session(True)
            return handler_input.response_builder.speak(speech).response