Exemple #1
0
    async def select_attachment_type_step(self, step_context: WaterfallStepContext):
        # Create the PromptOptions from the skill configuration which contain the list of configured skills.
        message_text = "What attachment type do you want?"
        reprompt_message_text = (
            "That was not a valid choice, please select a valid card type."
        )

        options = PromptOptions(
            prompt=MessageFactory.text(
                message_text, message_text, InputHints.expecting_input
            ),
            retry_prompt=MessageFactory.text(
                reprompt_message_text, reprompt_message_text, InputHints.expecting_input
            ),
            choices=[Choice("Inline"), Choice("Internet")],
        )

        return await step_context.prompt(ChoicePrompt.__name__, options)
Exemple #2
0
    async def selection_step(self, step_context: WaterfallStepContext):

        return await step_context.prompt(
            ChoicePrompt.__name__,
            PromptOptions(
                prompt=MessageFactory.text(
                    "Please indicate what do you want to know, or choose done to exit."
                ),
                choices=[
                    Choice("Covid-19 Stats"),
                    Choice("Covid-19 Social"),
                    Choice("Covid-19 Health"),
                    Choice("Covid-19 Donation"),
                    Choice('Covid-19 Places'),
                    Choice("Done")
                ],
            ),
        )
        async def exec_test(turn_context: TurnContext):
            dialog_context = await dialogs.create_context(turn_context)

            results: DialogTurnResult = await dialog_context.continue_dialog()

            if results.status == DialogTurnStatus.Empty:
                options = PromptOptions(
                    prompt=Activity(type=ActivityTypes.message,
                                    text="Please choose a color."),
                    choices=_color_choices,
                    style=ListStyle.auto,
                )
                await dialog_context.prompt("prompt", options)
            elif results.status == DialogTurnStatus.Complete:
                selected_choice = results.result
                await turn_context.send_activity(selected_choice.value)

            await convo_state.save_changes(turn_context)
Exemple #4
0
 async def destination_step(
         self, step_context: WaterfallStepContext) -> DialogTurnResult:
     """
     If a destination city has not been provided, prompt for one.
     :param step_context:
     :return DialogTurnResult:
     """
     goiylehoi_details = step_context.options
     if goiylehoi_details.hoatDong is None:
         return await step_context.end_dialog()
     else:
         if goiylehoi_details.diaDiem is None:
             message_text = "Bạn dự định du lịch lễ hội ở tỉnh nào của Việt Nam ?"
             prompt_message = MessageFactory.text(
                 message_text, message_text, InputHints.expecting_input)
             return await step_context.prompt(
                 TextPrompt.__name__, PromptOptions(prompt=prompt_message))
         return await step_context.next(goiylehoi_details.diaDiem)
 async def select_delivery_mode_step(
         self, step_context: WaterfallStepContext) -> DialogTurnResult:
     # Create the PromptOptions with the delivery modes supported.
     message = "What delivery mode would you like to use?"
     reprompt_message = (
         "That was not a valid choice, please select a valid delivery mode."
     )
     options = PromptOptions(
         prompt=MessageFactory.text(message, message,
                                    InputHints.expecting_input),
         retry_prompt=MessageFactory.text(reprompt_message,
                                          reprompt_message,
                                          InputHints.expecting_input),
         choices=[Choice("normal"),
                  Choice("expectReplies")],
     )
     return await step_context.prompt(
         self.select_delivery_mode_step.__name__, options)
    async def breakfast_step(
            step_context: WaterfallStepContext) -> DialogTurnResult:

        # Save the number of nights
        step_context.values["duration"] = step_context.result

        # Confirm people and duration
        await step_context.context.send_activity(
            MessageFactory.text(
                f"Okay, so {step_context.values['people']} people for {step_context.values['duration']} nights"
            ))

        # ConfirmPrompt - Is taking breakfast ?
        return await step_context.prompt(
            "IsTakingBreakfastPrompt",
            PromptOptions(
                prompt=MessageFactory.text("Will you be having breakfast?")),
        )
Exemple #7
0
    async def intro_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        if not self._luis_recognizer.is_configured:
            await step_context.context.send_activity(
                MessageFactory.text(
                    "NOTE: LUIS is not configured. To enable all capabilities, add 'LuisAppId', 'LuisAPIKey' and "
                    "'LuisAPIHostName' to the appsettings.json file.",
                    input_hint=InputHints.ignoring_input,
                ))

            return await step_context.next(None)
        message_text = (str(step_context.options) if step_context.options else
                        "What can I help you with today?")
        prompt_message = MessageFactory.text(message_text, message_text,
                                             InputHints.expecting_input)

        return await step_context.prompt(TextPrompt.__name__,
                                         PromptOptions(prompt=prompt_message))
Exemple #8
0
    async def origin_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """
        If an origin city has not been provided, prompt for one.
        :param step_context:
        :return DialogTurnResult:
        """
        booking_details = step_context.options

        # Capture the response to the previous step's prompt
        booking_details.destination = step_context.result
        if booking_details.origin is None:
            message_text = "From what city will you be travelling?"
            prompt_message = MessageFactory.text(message_text, message_text,
                                                 InputHints.expecting_input)
            return await step_context.prompt(
                TextPrompt.__name__, PromptOptions(prompt=prompt_message))
        return await step_context.next(booking_details.origin)
        async def exec_test(turn_context:TurnContext):
            dialog_context = await dialogs.create_context(turn_context)

            results = await dialog_context.continue_dialog()
            if (results.status == DialogTurnStatus.Empty):
                options = PromptOptions(
                    prompt = Activity(
                        type = ActivityTypes.message, 
                        text = "What is your favorite web site?"
                        )
                    )
                await dialog_context.prompt("urlprompt", options)

            elif results.status == DialogTurnStatus.Complete:
                reply = results.result
                await turn_context.send_activity(reply)

            await conv_state.save_changes(turn_context)
            async def exec_test(turn_context: TurnContext):
                dialog_context = await dialogs.create_context(turn_context)

                results: DialogTurnResult = await dialog_context.continue_dialog(
                )

                if results.status == DialogTurnStatus.Empty:
                    options = PromptOptions(prompt=Activity(
                        type=ActivityTypes.message, text="Please confirm."))
                    await dialog_context.prompt("prompt", options)
                elif results.status == DialogTurnStatus.Complete:
                    confirmed = results.result
                    if confirmed:
                        await turn_context.send_activity("true")
                    else:
                        await turn_context.send_activity("false")

                await convo_state.save_changes(turn_context)
 async def job_type_step(
         self, step_context: WaterfallStepContext) -> DialogTurnResult:
     if step_context.result.value == "Ja":
         print("[DEBUG] Recognized system cricital job claim")
         return await step_context.begin_dialog(
             ChoicePrompt.__name__,
             PromptOptions(prompt=MessageFactory.text(
                 "Zu welcher systemkritischen Gruppe gehören Sie?"),
                           choices=[
                               "Polizei", "Feuerwehr", "RichterIn",
                               "Staatsanwälte", "Justizvollzug",
                               "Rettungsdienst", "THW",
                               "Katastrophenschutz", "Mediziner", "Pfleger",
                               "Apotheher", "**Keine**"
                           ],
                           style=ListStyle.list_style))
     else:
         return await step_context.next(Choice("**Keine**"))
Exemple #12
0
    async def dates_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """Prompt a user to enter no more than 4 dates on which they want to get the reports.
        Validates the user input and re-promts is the validation isn't passed.


        Args:
            step_context (WaterfallStepContext): the context for the current dialog turn

        Returns:
            DialogTurnResult: result of calling the prompt stack manipulation method.
            Contains the users' response.
        """
        selected = step_context.result.value
        step_context.values["max"] = self.LAST_OPTION
        if selected == self.DONE_OPTION:
            return await step_context.end_dialog()

        max_period = await self.client.get_latest(
            channel=self.options_list[selected])
        self._max_period = max_period[0:-4]
        self._query = self.options_list[selected]

        message = (
            f"Введите максимум 4 периода через запятую в следующем формате: 2019Q1, 2019Q2 и т.п."
            f"Для получения данных за полный год выбирайте четвертый квартал."
            f"Чтобы получить только самый последний отчет, отправьте слово '{self.LAST_OPTION}' и только его"
            f"(запрос вида '2018Q2, {self.LAST_OPTION}' не сработает).  \n"
            f"Последний доступный отчет: {self._max_period}.  \n Чтобы завершить диалог, отправьте '{self.DONE_OPTION}'"
        )

        retry_message = (
            f"Пожалуйста, введите данные в правильном формате и на дату не позднее последней доступной."
            f"Напоминаю, последний доступный отчет: {self._max_period}\n\n"
            f"Правильный формат данных: 2019Q1, 2019Q2.\n\nЧтобы завершить диалог, отправьте '{self.DONE_OPTION}'"
        )

        prompt_options = PromptOptions(
            prompt=MessageFactory.text(message),
            retry_prompt=MessageFactory.text(retry_message),
            validations=self._max_period.replace(self._query, ""),
        )

        return await step_context.prompt('dates', options=prompt_options)
Exemple #13
0
    async def destination_step(
        self, step_context: WaterfallStepContext
    ) -> DialogTurnResult:
        """
        If a destination city has not been provided, prompt for one.
        :param step_context:
        :return DialogTurnResult:
        """
        booking_details = step_context.options

        if booking_details.destination is None:
            message_text = "Where would you like to travel to?"
            prompt_message = MessageFactory.text(
                message_text, message_text, InputHints.expecting_input
            )
            return await step_context.prompt(
                TextPrompt.__name__, PromptOptions(prompt=prompt_message)
            )
        return await step_context.next(booking_details.destination)
Exemple #14
0
    async def _select_skill_action_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        # Get the skill info based on the selected skill.
        selected_skill_id = step_context.result.value
        selected_skill = self._skills_config.SKILLS.get(selected_skill_id)

        # Remember the skill selected by the user.
        step_context.values[self._selected_skill_key] = selected_skill

        # Create the PromptOptions with the actions supported by the selected skill.
        message_text = f"Select an action # to send to **{selected_skill.id}** or just type in a message and it will be forwarded to the skill"
        options = PromptOptions(
            prompt=MessageFactory.text(message_text, message_text,
                                       InputHints.expecting_input),
            choices=self._get_skill_actions(selected_skill),
        )

        # Prompt the user to select a skill action.
        return await step_context.prompt("SkillActionPrompt", options)
 async def check_query_mobile_number(
         self, step_context: WaterfallStepContext) -> DialogTurnResult:
     if (step_context.result != None):
         step_context.values["PolicyNumber"] = step_context.result
     if (step_context.options.mobile_number != None):
         step_context.values[
             "MobileNumber"] = step_context.options.mobile_number
         return await step_context.next(None)
     else:
         return await step_context.prompt(
             phone,
             PromptOptions(
                 prompt=MessageFactory.text(
                     "Please provide your phone number."),
                 retry_prompt=MessageFactory.text(
                     "Enter a valid phone number."),
             ),
         )
     '''message_text = "Please provide your mobile number"
 async def check_query_date_of_birth(
         self, step_context: WaterfallStepContext) -> DialogTurnResult:
     if (step_context.result != None):
         step_context.values["MobileNumber"] = step_context.result
     if (step_context.options.date_of_birth != None):
         step_context.values[
             "DateOfBirth"] = step_context.options.date_of_birth
         return await step_context.next(None)
     else:
         return await step_context.prompt(
             date,
             PromptOptions(
                 prompt=MessageFactory.text(
                     "Please provide your date of birth."),
                 retry_prompt=MessageFactory.text(
                     "Enter a valid date of birth."),
             ),
         )
     '''message_text = "Please provide your Date of Birth"
    async def destination_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """
            If a destination city has not been provided, prompt for one.
            :param step_context:
            :return DialogTurnResult:
            """
        edit_booking_details = step_context.options

        # Capture the response to the previous step's prompt
        edit_booking_details.user_id = step_context.result

        if edit_booking_details.destination is None:
            message_text = "Where are you traveling to?"
            prompt_message = MessageFactory.text(message_text, message_text,
                                                 InputHints.expecting_input)
            return await step_context.prompt(
                TextPrompt.__name__, PromptOptions(prompt=prompt_message))
        return await step_context.next(edit_booking_details.destination)
Exemple #18
0
    async def intro_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """Initial prompt."""
        if (not self._configuration.get("LUIS_APP_ID", "")
                or not self._configuration.get("LUIS_API_KEY", "")
                or not self._configuration.get("LUIS_API_HOST_NAME", "")):
            await step_context.context.send_activity(
                MessageFactory.text(
                    "NOTE: LUIS is not configured. To enable all"
                    " capabilities, add 'LUIS_APP_ID', 'LUIS_API_KEY' and 'LUIS_API_HOST_NAME'"
                    " to the config.py file."))

            return await step_context.next(None)

        return await step_context.prompt(
            TextPrompt.__name__,
            PromptOptions(
                prompt=MessageFactory.text("What can I help you with today?")),
        )
Exemple #19
0
    async def confirm_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """Confirm the information the user has provided."""
        booking_details = step_context.options

        # Capture the results of the previous step
        booking_details.budget = step_context.result
        message_text = (
            f"Please confirm, I have you traveling to: { booking_details.destination } from: "
            f"{ booking_details.origin } on: { booking_details.travel_date} return:{ booking_details.return_date}"
            f" Budget: { booking_details.budget}.")
        #        prompt_message = MessageFactory.text(
        #            message_text, message_text, InputHints.expecting_input
        #        )

        # Offer a YES/NO prompt.
        return await step_context.prompt(
            ConfirmPrompt.__name__,
            PromptOptions(prompt=MessageFactory.text(message_text)))
Exemple #20
0
    async def selection_step(self, step_context: WaterfallStepContext):

        self.new_country = False

        step_context.values["country"] = step_context.result

        return await step_context.prompt(
        ChoicePrompt.__name__,
        PromptOptions(
            prompt=MessageFactory.text("Please indicate what do you want to know, or choose done to exit."),
            choices=[Choice("Covid-19 Cases"), 
                     Choice("Covid-19 Deaths"), 
                     Choice("Covid-19 Tests"), 
                     Choice('Covid-19 Twitter') ,
                     Choice('Covid-19 Meme') ,
                     Choice('Covid-19 Donation'), 
                     Choice("Done")],
        ),
    )
Exemple #21
0
        async def exec_test(turn_context: TurnContext) -> None:

            dialogContext = await dialogs.create_context(turn_context)
            results = await dialogContext.continue_dialog()

            if results.status == DialogTurnStatus.Empty:
                await dialogContext.begin_dialog(
                    'NumberPrompt',
                    PromptOptions(
                        prompt=MessageFactory.text('Enter quantity of cable')))
            else:
                if results.status == DialogTurnStatus.Complete:
                    numberResult = results.result
                    await turn_context.send_activity(
                        MessageFactory.text(
                            f"You asked me for '{numberResult}' meters of cable."
                        ))

            await conver_state.save_changes(turn_context)
    async def intro_step(step_context: WaterfallStepContext) -> DialogTurnResult:
        """
        Intro step. Triggered upon any interaction from the user to this bot.
        """

        # Ask what to do
        message = (
            str(step_context.options)
            if step_context.options
            else "What can I help you with today?"
        )

        # TextPromp - How can I help you ?
        return await step_context.prompt(
            "ActPrompt",
            PromptOptions(
                prompt=MessageFactory.text(message)
            ),
        )
    async def ask_update_step(
        self, step_context: WaterfallStepContext
    ) -> DialogTurnResult:
        
        okr_details = step_context.options   
        if okr_details.okr_update_reply  is None:

            #message_text = self._action.get_random_utterance('msg_start_update') 
            message_text =  self._action.get_okr_update_status(False) + '\n'
            message_text = message_text + 'call API update OKR page with entity < ' + okr_details.get_okr_type()  + '>'
                         
                           
            prompt_message = MessageFactory.text(
                message_text, message_text, InputHints.ignoring_input
            )                
                
            return await step_context.prompt(
                TextPrompt.__name__, PromptOptions(prompt=prompt_message)
            )
        return await step_context.next(okr_details.okr_update_reply)
Exemple #24
0
    async def choice_card_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """
        1. Prompts the user if the user is not in the middle of a dialog.
        2. Re-prompts the user when an invalid input is received.
        """

        # Prompt the user with the configured PromptOptions.
        return await step_context.prompt(
            CARD_PROMPT,
            PromptOptions(
                prompt=MessageFactory.text(
                    "What card would you like to see? You can click or type the card name"
                ),
                retry_prompt=MessageFactory.text(
                    "That was not a valid choice, please select a card or number from 1 "
                    "to 9."),
                choices=self.get_choices(),
            ),
        )
Exemple #25
0
    async def name_process_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        user_profile = await self.user_profile_accessor.get(
            step_context.context, UserData)
        if (user_profile.name != None and user_profile.user_greeted == True):
            message_text = "What else can I do for you " + user_profile.name + " ?"
        else:
            user_profile.user_greeted = True
            message_text = "Hi " + user_profile.name + ", How can I help you today?"
        '''prompt_message = MessageFactory.text(message_text, message_text, InputHints.expecting_input)       
        await step_context.context.send_activity(message)'''

        message = Activity(
            type=ActivityTypes.message,
            attachments=[self.create_adaptive_card(message_text)],
        )
        message.attachments[0].content['body'][0]['columns'][0]['items'][0][
            'text'] = message_text
        return await step_context.prompt(TextPrompt.__name__,
                                         PromptOptions(prompt=message))
Exemple #26
0
    async def confirm_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """
        Confirm the information the user has provided.
        :param step_context:
        :return DialogTurnResult:
        """
        restaurant_details = step_context.options

        # Capture the results of the previous step
        restaurant_details.loc = step_context.result
        message_text = (
            f"So you're looking to eat {restaurant_details.food} in {restaurant_details.loc}, is that right?"
        )
        prompt_message = MessageFactory.text(message_text, message_text,
                                             InputHints.expecting_input)

        # Offer a YES/NO prompt.
        return await step_context.prompt(ConfirmPrompt.__name__,
                                         PromptOptions(prompt=prompt_message))
        async def exec_test(turn_context: TurnContext) -> None:

            dialog_context = await dialogs.create_context(turn_context)
            results = await dialog_context.continue_dialog()

            if results.status == DialogTurnStatus.Empty:
                await dialog_context.begin_dialog(
                    "NumberPrompt",
                    PromptOptions(prompt=MessageFactory.text(
                        "How much money is in your gaming account?")),
                )
            else:
                if results.status == DialogTurnStatus.Complete:
                    number_result = results.result
                    await turn_context.send_activity(
                        MessageFactory.text(
                            f"You say you have ${number_result} in your gaming account."
                        ))

            await conver_state.save_changes(turn_context)
        async def exec_test(turn_context: TurnContext) -> None:
            dialog_context: DialogContext = await dialogs.create_context(turn_context)

            results: DialogTurnResult = await dialog_context.continue_dialog()

            if results.status == DialogTurnStatus.Empty:
                options = PromptOptions(
                    prompt=Activity(type=ActivityTypes.message, text="Enter a number."),
                    retry_prompt=Activity(
                        type=ActivityTypes.message, text="You must enter a number."
                    ),
                )
                await dialog_context.prompt("NumberPrompt", options)
            elif results.status == DialogTurnStatus.Complete:
                number_result = results.result
                await turn_context.send_activity(
                    MessageFactory.text(f"Bot received the number '{number_result}'.")
                )

            await convo_state.save_changes(turn_context)
    async def orderid_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """
        If an origin city has not been provided, prompt for one.
        :param step_context:
        :return DialogTurnResult:
        """
        ordering_details = step_context.options

        # Capture the response to the previous step's prompt
        ordering_details.email = step_context.result
        if ordering_details.orderid is None:
            message_text = "Please enter your order id."
            prompt_message = MessageFactory.text(message_text, message_text,
                                                 InputHints.expecting_input)
            return await step_context.prompt(
                TextPrompt.__name__, PromptOptions(prompt=prompt_message))
        # return await step_context.next(ordering_details.orderid)
        user_input = ""
        return await step_context.next(user_input)
Exemple #30
0
        async def exec_test(turn_context: TurnContext):
            dialog_context = await dialogs.create_context(turn_context)

            results = await dialog_context.continue_dialog()
            if results.status == DialogTurnStatus.Empty:
                options = PromptOptions(
                    prompt=Activity(
                        type=ActivityTypes.message, text="please add an attachment."
                    ),
                    retry_prompt=Activity(
                        type=ActivityTypes.message, text="please try again."
                    ),
                )
                await dialog_context.prompt("AttachmentPrompt", options)
            elif results.status == DialogTurnStatus.Complete:
                attachment = results.result[0]
                content = MessageFactory.text(attachment.content)
                await turn_context.send_activity(content)

            await convo_state.save_changes(turn_context)