async def initial_step(
        self, step_context: WaterfallStepContext
    ) -> DialogTurnResult:
        timex = step_context.options

        prompt_msg_text = "On what date would you like to travel?"
        prompt_msg = MessageFactory.text(
            prompt_msg_text, prompt_msg_text, InputHints.expecting_input
        )

        reprompt_msg_text = "I'm sorry, for best results, please enter your travel date " \
                            "including the month, day and year."
        reprompt_msg = MessageFactory.text(
            reprompt_msg_text, reprompt_msg_text, InputHints.expecting_input
        )

        if timex is None:
            # We were not given any date at all so prompt the user.
            return await step_context.prompt(
                DateTimePrompt.__name__,
                PromptOptions(prompt=prompt_msg, retry_prompt=reprompt_msg),
            )
        # We have a Date we just need to check it is unambiguous.
        if "definite" not in Timex(timex).types:
            # This is essentially a "reprompt" of the data we were given up front.
            return await step_context.prompt(
                DateTimePrompt.__name__, PromptOptions(prompt=reprompt_msg)
            )

        return await step_context.next(DateTimeResolution(timex=timex))
Beispiel #2
0
    async def initial_step(
        self, step_context: WaterfallStepContext
    ) -> DialogTurnResult:
        """Prompt for the date."""
        timex = step_context.options

        prompt_msg = "On what date would you like to travel?"
        reprompt_msg = (
            "I'm sorry, for best results, please enter your travel "
            "date including the month, day and year."
        )

        if timex is None:
            # We were not given any date at all so prompt the user.
            return await step_context.prompt(
                DateTimePrompt.__name__,
                PromptOptions(  # pylint: disable=bad-continuation
                    prompt=MessageFactory.text(prompt_msg),
                    retry_prompt=MessageFactory.text(reprompt_msg),
                ),
            )
        else:
            # We have a Date we just need to check it is unambiguous.
            if "definite" in Timex(timex).types:
                # This is essentially a "reprompt" of the data we were given up front.
                return await step_context.prompt(
                    DateTimePrompt.__name__, PromptOptions(prompt=reprompt_msg)
                )
            else:
                return await step_context.next(DateTimeResolution(timex=timex))
Beispiel #3
0
    async def option_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        a1 = "tìm hiểu lễ hội việt nam"
        a2 = "tìm kiếm các lễ hội"
        a3 = "gợi ý du lịch lễ hội"

        if (step_context.result == a1):
            return await step_context.begin_dialog(self._lehoi_dialog_id,
                                                   LeHoiDetails())

        if (step_context.result == a2):
            get_text = "Bạn có thể tìm kiếm các lễ hội theo địa điểm hoặc các thông tin khác liên quan đến lễ hội như dân tộc, mục đích, hoạt động trong lễ hội..."
            get_weather_message = MessageFactory.text(
                get_text, get_text, InputHints.expecting_input)
            # await step_context.context.send_activity(get_weather_message)
            return await step_context.prompt(
                TextPrompt.__name__, PromptOptions(prompt=get_weather_message))

        if (step_context.result == a3):
            get_text = "Bạn thích tham gia những hoạt động gì khi du lịch lễ hội?"
            get_weather_message = MessageFactory.text(
                get_text, get_text, InputHints.expecting_input)
            # await step_context.context.send_activity(get_weather_message)
            return await step_context.prompt(
                TextPrompt.__name__, PromptOptions(prompt=get_weather_message))
        else:
            didnt_understand_text = (
                "Xin lỗi, bạn có thể lựa chọn một trong các chức năng sau (@_@;)"
            )
            didnt_understand_message = MessageFactory.text(
                didnt_understand_text, didnt_understand_text,
                InputHints.ignoring_input)
            await step_context.context.send_activity(didnt_understand_message)
            return await step_context.next(None)
Beispiel #4
0
    async def third_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        step_context.values["get_employee_id"] = False
        if step_context.values['employee_id'] == 'Required':

            if step_context.result != True:

                #step_context.values["name"] = step_context.result

                # We can send messages to the user at any point in the WaterfallStep.
                await step_context.context.send_activity(
                    MessageFactory.text(
                        f"You need to get your employee Id created first"))

                step_context.values["get_employee_id"] = True
                get_employee_id = step_context.values["get_employee_id"]
                # WaterfallStep always finishes with the end of the Waterfall or
                # with another dialog; here it is a Prompt Dialog.
                return await step_context.prompt(
                    ConfirmPrompt.__name__,
                    PromptOptions(prompt=MessageFactory.text(
                        "Would you like me to put in a request to HR to get your employee Id created"
                    )),
                )
            else:
                step_context.values["get_employee_id"] = False
                return await step_context.prompt(
                    TextPrompt.__name__,
                    PromptOptions(prompt=MessageFactory.text(
                        "Please Provide Your Employee ID.")),
                )
        return await step_context.next(1)
Beispiel #5
0
 async def intro_step(
         self, step_context: WaterfallStepContext) -> DialogTurnResult:
     """Initial prompt."""
     return await step_context.prompt(
         TextPrompt.__name__,
         PromptOptions(
             prompt=MessageFactory.text("What can I help you with today?")))
    async def _select_skill_action_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """
        Render a prompt to select the action for the skill.
        """

        # 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 "
            f"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)
Beispiel #7
0
    async def act_step(self,
                       step_context: WaterfallStepContext) -> DialogTurnResult:

        details = step_context.context.activity.text

        score_dict = pointExtract(details)
        #price = {'low':1,'high':20000}
        recommend_id, recommend_result = adjust(score_dict)
        print('推荐id为:')
        print(str(recommend_id + 1))
        welcome_card = self.create_adaptive_card_attachment(recommend_id)
        response = MessageFactory.attachment(welcome_card)
        await step_context.context.send_activity(response)

        message_text = str(recommend_result)
        prompt_message = MessageFactory.text(message_text, message_text,
                                             InputHints.ignoring_input)
        await step_context.context.send_activity(prompt_message)

        #return await step_context.end_dialog()
        msg_txt = (f"您对这个推荐结果满意吗?")

        message = MessageFactory.text(msg_txt, msg_txt,
                                      InputHints.expecting_input)
        return await step_context.prompt(TextPrompt.__name__,
                                         PromptOptions(prompt=message))
    async def time_step(self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """
        If a delivery time has not been provided, prompt for one.
        :param step_context:
        :return DialogTurnResult:
        """
        LOGGER.debug(msg=f"{CreateDeliveryDialog.__name__}: time step.")

        # Set the delivery destination to what they entered in response to the destination prompt.
        delivery: Delivery = step_context.values[Keys.DELIVERY_DIALOG_STATE.value]

        # capture the response from the previous step
        delivery.destination = step_context.result

        if delivery.time is None:
            message_text = messages.DELIVERY_TIME_PROMPT % (delivery.item, delivery.destination)

            prompt_options = PromptOptions(
                prompt=MessageFactory.text(
                    message_text,
                    message_text,
                    InputHints.expecting_input
                ),
                retry_prompt=MessageFactory.text(messages.VALID_DELIVERY_TIME_PROMPT),
            )
            return await step_context.prompt(DateTimePrompt.__name__, prompt_options)
        return await step_context.next(delivery.time)
    async def card_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """Sends a message with an Adaptive card attachment for a user to fill.
        The autoreply will be set based on the user input in this step. All inputs are also validated.

        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.
        """
        self.user_info: UserProfile = await self.accessor.get(
            step_context.context, UserProfile)
        msg = "Я помогу тебе установить автоответ и ничего не забыть! Для этого заполни, пожалуйста, маленькую форму ниже или отправь 'Завершить'"
        await step_context.context.send_activity(msg)
        # не забыть удалить messageback из джейсона карты, т.к. код уже заточен
        # под postback
        card_msg = Activity(
            type=ActivityTypes.message,
            attachments=[self._populate_with_data(rel_path=self.CARD_PATH)],
        )
        prompt_options = PromptOptions(
            prompt=None,
            retry_prompt=MessageFactory.text("Пожалуйста, исправь ошибки"))
        await step_context.context.send_activity(MessageFactory.text(msg))
        response = await step_context.context.send_activity(card_msg)
        # Adaptive cards don't support validation, so to ensure it
        # we need to create a fake prompt which won't be visible to the user
        return await step_context.prompt("fake", options=prompt_options)
    async def _select_skill_group_step(self,
                                       step_context: WaterfallStepContext):
        """
        Render a prompt to select the group of skills to use.
        """

        # Remember the delivery mode selected by the user.
        step_context.values[DELIVERY_MODE_NAME] = step_context.result.value

        # Create the PromptOptions with the types of supported skills.
        message_text = "What group of skills would you like to use?"
        retry_message_text = (
            "That was not a valid choice, please select a valid skill group.")

        choices = []
        groups = []
        for skill in self._skills_config.SKILLS.values():
            if skill.group not in groups:
                groups.append(skill.group)
                choices.append(Choice(skill.group))

        options = PromptOptions(
            prompt=MessageFactory.text(message_text, message_text,
                                       InputHints.expecting_input),
            retry_prompt=MessageFactory.text(retry_message_text,
                                             retry_message_text,
                                             InputHints.expecting_input),
            choices=choices,
        )

        # Prompt the user to select a type of skill.
        return await step_context.prompt(SKILL_GROUP_PROMPT, options)
 async def intro_step(self, step_context: WaterfallStepContext) -> DialogTurnResult:
     """Initial prompt."""
     return await step_context.prompt(TextPrompt.__name__, PromptOptions(
             prompt=MessageFactory.text("Чем могу помочь? "
                                        "\n 1 - первый диалог "
                                        "\n 2 - второй диалог "
                                        "\n 3 - третий диалог с адаптивной карточкой")),)
    async def dep_step(self,
                       step_context: WaterfallStepContext) -> DialogTurnResult:
        """Prompts the user to choose the department to which their question is related and stores the choice.
        Validates the input and re-promts the user if the validation is not 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.
        """
        self.selected_keys = []

        message = (
            f"К какому отделу относится ваш вопрос? Подсказка: ФАО отвечает за всевозможные "
            f"согласования и расчеты, бухгалтерия - за правильный документооборот."
            f"Чтобы завершить работу с ботом, выберите '{self.DONE_OPTION}'.")

        options = self.options_list.copy()
        path_link = await self.client.download_file(
            self.SITE_ID, self.DRIVE_ID,
            "FunctionalAreas/selector_dialog_tree.json:/content")

        self.json_path = json.loads(path_link.decode("utf-8"))

        prompt_options = PromptOptions(
            prompt=MessageFactory.text(message),
            retry_prompt=MessageFactory.text(
                "Пожалуйста, выберите вариант из списка."),
            choices=self._to_choices(options),
            style=ListStyle.suggested_action,
        )
        return await step_context.prompt('level1', options=prompt_options)
    async def type_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """Prompts the user to choose the functional area to which their question is related and stores the choice.
        Validates the input and re-promts the user if the validation is not 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

        if selected == self.DONE_OPTION:
            return await step_context.end_dialog()

        self.selected_keys.append(selected)

        message = f"К какой части функционала {selected} относится ваш вопрос? Выберите вариант из списка. "
        f"Чтобы завершить работу с ботом, выберите '{self.DONE_OPTION}'."
        options = list(
            self._dict_traverser(self.selected_keys, self.json_path).keys())
        options.append(self.DONE_OPTION)

        prompt_options = PromptOptions(
            prompt=MessageFactory.text(message),
            retry_prompt=MessageFactory.text(
                "Пожалуйста, выберите вариант из списка."),
            choices=self._to_choices(options),
        )
        return await step_context.prompt('level2', options=prompt_options)
Beispiel #14
0
    async def channel_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """Prompts user to choose a channel for which they want to get the reports.
        Validates user input to ensure that only existing channels are sent back to the bot.

        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.options if step_context.options is not None else []
        step_context.values[self.SELECTED_CHANNEL] = selected

        if len(selected) == 0:
            message = (
                f"Данные по какому рынку вас интересуют? Чтобы завершить диалог с ботом, выберите '{self.DONE_OPTION}'."
            )
        else:
            message = (f"Ваш выбор: {selected[0]}.")

        options = self.options_list.copy()
        prompt_options = PromptOptions(
            prompt=MessageFactory.text(message),
            retry_prompt=MessageFactory.text(
                "Пожалуйста выберите вариант из списка."),
            choices=self._to_choices(options),
            style=ListStyle.suggested_action,
        )

        return await step_context.prompt('channels', options=prompt_options)
 async def GetIntro(self, waterfall_step: WaterfallStepContext):
     #return await waterfall_step._turn_context.send_activity("Welcome to Petrol Station locator.\n\nPlease enter area code to search")
     return await waterfall_step.prompt(
         "number_prompt",
         PromptOptions(prompt=MessageFactory.text(
             "Welcome to Petrol Station locator.\n\nPlease enter area code to search"
         )))
    async def destination_step(self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """
        If a delivery destination has not been provided, prompt for one.
        :param step_context:
        :return DialogTurnResult:
        """
        LOGGER.debug(msg=f"{CreateDeliveryDialog.__name__}: destination step.")

        # Set the delivery item to what they entered in response to the create delivery prompt.
        delivery: Delivery = step_context.values[Keys.DELIVERY_DIALOG_STATE.value]

        # capture the response from the previous step
        delivery.item = step_context.result

        if delivery.destination is None:
            message_text = messages.DELIVERY_DESTINATION_PROMPT % delivery.item
            prompt_options = PromptOptions(
                prompt=MessageFactory.text(
                    message_text,
                    message_text,
                    InputHints.expecting_input
                )
            )
            return await step_context.prompt(TextPrompt.__name__, prompt_options)
        return await step_context.next(delivery.destination)
    async def confirm_step(self, step_context: WaterfallStepContext) -> DialogTurnResult:
        LOGGER.debug(msg=f"{CreateDeliveryDialog.__name__}: confirmation step.")

        # Set the delivery destination to what they entered in response to the destination prompt.
        delivery: Delivery = step_context.values[Keys.DELIVERY_DIALOG_STATE.value]

        # capture the response from the previous step
        delivery.time = step_context.result[0].value

        message_text = f"""{
        messages.DELIVERY_SCHEDULED % (delivery.item, delivery.destination, delivery.time)}
        {messages.IS_THAT_ALL}"""

        prompt_options = PromptOptions(
            prompt=MessageFactory.text(message_text)
        )

        DeliveryCard["body"][0]["text"] = f"Item: {delivery.item}"
        DeliveryCard["body"][1]["text"] = f"Destination: {delivery.destination}"
        DeliveryCard["body"][2]["text"] = f"Time: {delivery.time}"

        await step_context.context.send_activity(
            Activity(
                type=ActivityTypes.message,
                text=MessageFactory.text(message_text),
                attachments=[
                    CardFactory.adaptive_card(DeliveryCard)
                ],
            )
        )

        return await step_context.prompt(ConfirmPrompt.__name__, prompt_options)
        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 send an event."))

                try:
                    await dialog_context.prompt("EventActivityPrompt", options)
                    await dialog_context.prompt("Non existent id", options)
                except Exception as err:
                    self.assertIsNotNone(err.data["DialogContext"]  # pylint: disable=no-member
                                         )
                    self.assertEqual(
                        err.data["DialogContext"][  # pylint: disable=no-member
                            "active_dialog"],
                        "EventActivityPrompt",
                    )
                else:
                    raise Exception("Should have thrown an error.")

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

            await convo_state.save_changes(turn_context)
    async def _select_delivery_mode_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """
        Render a prompt to select the delivery mode to use.
        """

        # Create the PromptOptions with the delivery modes supported.
        message_text = (str(step_context.options) if step_context.options else
                        "What delivery mode would you like to use?")
        retry_message_text = (
            "That was not a valid choice, please select a valid delivery mode."
        )

        options = PromptOptions(
            prompt=MessageFactory.text(message_text, message_text,
                                       InputHints.expecting_input),
            retry_prompt=MessageFactory.text(retry_message_text,
                                             retry_message_text,
                                             InputHints.expecting_input),
            choices=[
                Choice(DeliveryModes.normal.value),
                Choice(DeliveryModes.expect_replies.value),
            ],
        )

        # Prompt the user to select a delivery mode.
        return await step_context.prompt(DELIVERY_MODE_PROMPT, options)
    async def subscription_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        if step_context.result:
            vm_details = step_context.options
            vm_details.name = step_context.result

        if vm_details.subscription is None:
            # Ask for the Subscription
            list_of_choices = [
                Choice(value=v)
                for v in AzureConfig.AZURE_SUBSCRIPTION_ID_MAP.keys()
            ]

            # If there's only one subscription, no need to ask
            if len(list_of_choices) == 1:
                subscription_id = AzureConfig.AZURE_SUBSCRIPTION_ID_MAP.values(
                )[0]
                vm_details.subscription = subscription_id
                return step_context.next(vm_details.subscription)

            choice_message_text = "In which subscription?"
            prompt_message = MessageFactory.text(choice_message_text,
                                                 choice_message_text,
                                                 InputHints.expecting_input)

            return await step_context.prompt(
                ChoicePrompt.__name__,
                PromptOptions(prompt=prompt_message,
                              choices=list_of_choices,
                              style=ListStyle.auto))

        return await step_context.next(vm_details.subscription)
    async def _select_skill_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """
        Render a prompt to select the skill to call.
        """

        skill_group = step_context.result.value

        # Create the PromptOptions from the skill configuration which contain the list of configured skills.
        message_text = "What skill would you like to call?"
        retry_message_text = "That was not a valid choice, please select a valid skill."

        options = PromptOptions(
            prompt=MessageFactory.text(message_text, message_text,
                                       InputHints.expecting_input),
            retry_prompt=MessageFactory.text(retry_message_text,
                                             retry_message_text,
                                             InputHints.expecting_input),
            style=ListStyle.list_style,
            choices=[
                Choice(skill.id)
                for skill in self._skills_config.SKILLS.values()
                if skill.group.lower().startswith(skill_group.lower())
            ],
        )

        # Prompt the user to select a skill.
        return await step_context.prompt(SKILL_PROMPT, options)
    async def handle_attachment_step(self, step_context: WaterfallStepContext):
        file_text = ""
        file_content = ""

        for file in step_context.context.activity.attachments:
            remote_file_url = file.content_url
            local_file_name = os.path.join(tempfile.gettempdir(), file.name)
            with urllib.request.urlopen(remote_file_url) as response, open(
                local_file_name, "wb"
            ) as out_file:
                shutil.copyfileobj(response, out_file)

            file_content = open(local_file_name, "r").read()
            file_text += f'Attachment "{ file.name }" has been received.\r\n'
            file_text += f'File content: { file_content }\r\n'

        await step_context.context.send_activity(MessageFactory.text(file_text))

        # Ask to upload another file or end.
        message_text = "Do you want to upload another file?"
        reprompt_message_text = "That's an invalid choice."

        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
            ),
        )

        return await step_context.prompt(ConfirmPrompt.__name__, options)
Beispiel #23
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)

        reply = MessageFactory.text("Mời lựa chọn:")

        reply.suggested_actions = SuggestedActions(actions=[
            CardAction(title="Tìm hiểu lễ hội Việt Nam",
                       type=ActionTypes.im_back,
                       value="Tìm hiểu lễ hội Việt Nam"),
            CardAction(title="Tìm kiếm các lễ hội",
                       type=ActionTypes.im_back,
                       value="Tìm kiếm các lễ hội"),
            CardAction(title="Gợi ý du lịch lễ hội",
                       type=ActionTypes.im_back,
                       value="Gợi ý du lịch lễ hội"),
        ])

        # return await step_context.context.send_activity(reply)
        return await step_context.prompt(TextPrompt.__name__,
                                         PromptOptions(prompt=reply))
Beispiel #24
0
    async def selection_step(self, step_context: WaterfallStepContext) -> DialogTurnResult:
        # step_context.options will contains the value passed in begin_dialog or replace_dialog.
        # if this value wasn't provided then start with an emtpy selection list.  This list will
        # eventually be returned to the parent via end_dialog.
        selected: [str] = step_context.options if step_context.options is not None else []
        step_context.values[self.COMPANIES_SELECTED] = selected

        if len(selected) == 0:
            message = f"Please choose a company to review, or `{self.DONE_OPTION}` to finish."
        else:
            message = f"You have selected **{selected[0]}**. You can review an additional company, "\
                      f"or choose `{self.DONE_OPTION}` to finish. "

        # create a list of options to choose, with already selected items removed.
        options = self.company_options.copy()
        options.append(self.DONE_OPTION)
        if len(selected) > 0:
            options.remove(selected[0])

        # prompt with the list of choices
        prompt_options = PromptOptions(
            prompt=MessageFactory.text(message),
            retry_prompt=MessageFactory.text("Please choose an option from the list."),
            choices=self._to_choices(options)
        )
        return await step_context.prompt(ChoicePrompt.__name__, prompt_options)
 async def domanda_step(
         self, step_context: WaterfallStepContext) -> DialogTurnResult:
     return await step_context.prompt(
         TextPrompt.__name__,
         PromptOptions(prompt=MessageFactory.text("Cosa vuoi sapere?")),
     )
     return step_context.next(0)
Beispiel #26
0
    async def selection_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        """Prompts user to choose a branch (task the user want to perform via the bot).
        List of branches is contained in the ways_options attribute.
        Also checks if the user entered something that is not in the list and re-promts if that's the case.

        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.
        """
        # Create an object in which to collect information within the dialog.
        selected: List[str] = step_context.options if step_context.options is not None else []
        step_context.values[self.SELECTED_WAY] = selected

        if len(selected) == 0:
            message = (
                f"Выберите из списка, какую информацию вы хотите получить"
                f"или выберите '{self.DONE_OPTION}', чтобы закончить работу")

        else:
            message = (f"Ваш выбор: {selected[0]}")

        # Ask the user to select the action they want to perform
        prompt_options = PromptOptions(
            prompt=MessageFactory.text(message),
            choices=self._to_choices(self.ways_options),
            retry_prompt=MessageFactory.text(
                "Пожалуйста выберите вариант из списка."),
            style=ListStyle.list_style,
        )
        return await step_context.prompt("top_level_choice", prompt_options)
Beispiel #27
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 "您好!有什么能帮到您的吗?"
        )
        '''
        message_text = ("您好!有什么能帮到您的吗?")

        prompt_message = MessageFactory.text(message_text, message_text,
                                             InputHints.expecting_input)

        return await step_context.prompt(TextPrompt.__name__,
                                         PromptOptions(prompt=prompt_message))
    async def name_step(self, step_context: WaterfallStepContext) -> DialogTurnResult:
        step_context.values["transport"] = step_context.result.value

        return await step_context.prompt(
            TextPrompt.__name__,
            PromptOptions(prompt=MessageFactory.text("Please enter your name.")),
        )
Beispiel #29
0
    async def picture_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        age = step_context.result
        step_context.values["age"] = age

        msg = ("No age given."
               if step_context.result == -1 else f"I have your age as {age}.")

        # We can send messages to the user at any point in the WaterfallStep.
        await step_context.context.send_activity(MessageFactory.text(msg))

        if step_context.context.activity.channel_id == "msteams":
            # This attachment prompt example is not designed to work for Teams attachments, so skip it in this case
            await step_context.context.send_activity(
                "Skipping attachment prompt in Teams channel...")
            return await step_context.next(None)

        # WaterfallStep always finishes with the end of the Waterfall or with another dialog; here it is a Prompt
        # Dialog.
        prompt_options = PromptOptions(
            prompt=MessageFactory.text(
                "Please attach a profile picture (or type any message to skip)."
            ),
            retry_prompt=MessageFactory.text(
                "The attachment must be a jpeg/png image file."),
        )
        return await step_context.prompt(AttachmentPrompt.__name__,
                                         prompt_options)
Beispiel #30
0
    async def budget_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.return_date = step_context.result

        if booking_details.budget is None:
            return await step_context.prompt(
                TextPrompt.__name__,
                PromptOptions(
                    prompt=MessageFactory.text("What is you budget ?")
                ),
            )  # pylint: disable=line-too-long,bad-continuation

            #message_text = "What is you budget ?"
            #prompt_message = MessageFactory.text(
            #   message_text, message_text, InputHints.expecting_input
            #)
            #return await step_context.prompt(TextPrompt.__name__, PromptOptions(prompt=message_text))
        return await step_context.next(booking_details.budget)