def __init__(self, user_state: UserState, course: Course, luis_recognizer: Recognizer, dialog_id: str = None):
        super(StudentProfileDialog, self).__init__(dialog_id or StudentProfileDialog.__name__)
        self.course = course
        self.luis_recognizer = luis_recognizer

        # create accessor
        self.student_profile_accessor: StatePropertyAccessor = user_state.create_property("StudentProfile")

        # add dialogs
        self.add_dialog(
            WaterfallDialog(
                WaterfallDialog.__name__,
                [
                    self.name_step,
                    self.admission_number_step,
                    self.picture_step,
                    self.courses_step,
                    self.summary_step
                ]
            ),
        )

        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(ChoicePrompt(ChoicePrompt.__name__))
        self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__))
        self.add_dialog(AttachmentPrompt(AttachmentPrompt.__name__, StudentProfileDialog.picture_prompt_validator))
        self.add_dialog(CourseQueryDialog(course, luis_recognizer, CourseQueryDialog.__name__))

        self.initial_dialog_id = WaterfallDialog.__name__
Пример #2
0
    def __init__(self, user_profile_accessor: StatePropertyAccessor,
                 logged_users: Dict[str, str]):
        super().__init__(AddPersonDialog.__name__)

        self.add_dialog(AttachmentPrompt(AttachmentPrompt.__name__))
        self.add_dialog(ChoicePrompt(ChoicePrompt.__name__))
        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(
            WaterfallDialog('AddPersonMainWF', [
                self._init_step,
                self._select_picture,
                self._select_insert_mode,
            ]))

        self.add_dialog(
            WaterfallDialog('AddPersonFromScratchWF', [
                self._insert_name, self._insert_surname,
                self._confirm_name_surname, self._add_to_new_db
            ]))

        self.add_dialog(
            WaterfallDialog('AddPersonFromExistingWF', [
                self._select_from_db, self._confirm_choice,
                self._add_to_existing_db
            ]))

        self.logged_users = logged_users
        self.user_profile_accessor = user_profile_accessor

        self.initial_dialog_id = 'AddPersonMainWF'
Пример #3
0
    def __init__(self, dialog_id: str = None):
        super(SuggestBooksDialog,
              self).__init__(dialog_id or SuggestBooksDialog.__name__)

        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(
            TextPrompt("TextPromptTitle", SuggestBooksDialog.titleValidator))
        self.add_dialog(
            ConfirmPrompt(ConfirmPrompt.__name__,
                          SuggestBooksDialog.yes_noValidator))
        self.add_dialog(
            WaterfallDialog(
                "WFDialog",
                [self.showBooks_step, self.confirm_step, self.add_step]))

        self.initial_dialog_id = "WFDialog"
    def __init__(self, dialog_id: str):
        super().__init__(dialog_id)

        dialog = WaterfallDialog("waterfall", [self.step1, self.step2])
        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(dialog)
        self.initial_dialog_id = dialog.id
Пример #5
0
    def __init__(self, dialog_id: str = None):
        super(WishlistDialog, self).__init__(dialog_id
                                             or WishlistDialog.__name__)
        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(TextPrompt("TitoloLibro",
                                   WishlistDialog.validateTitle))
        self.add_dialog(
            ConfirmPrompt(ConfirmPrompt.__name__,
                          WishlistDialog.yes_noValidator))
        self.add_dialog(
            WaterfallDialog("WFDialog", [
                self.first_step, self.input_step, self.confirm_step,
                self.cancel_step, self.final_step
            ]))

        self.initial_dialog_id = "WFDialog"
        self._luis_recognizer = None
Пример #6
0
    def __init__(self, dialog_id: str = None):
        super(FindBookDialog, self).__init__(dialog_id
                                             or FindBookDialog.__name__)
        self.add_dialog(
            TextPrompt("TextPromptLibro", FindBookDialog.validateName))
        self.add_dialog(
            TextPrompt("TextPromptSito", FindBookDialog.validateSite))
        self.add_dialog(
            ConfirmPrompt(ConfirmPrompt.__name__,
                          FindBookDialog.yes_noValidator))
        self.add_dialog(
            WaterfallDialog("WFDialog", [
                self.prompt_step, self.search_step, self.confirmRec_step,
                self.prompt_to_wish, self.confirm_step, self.add_to_wishlist
            ]))

        self.initial_dialog_id = "WFDialog"
Пример #7
0
    def __init__(self, user_state: UserState):
        super(MainDialog, self).__init__(MainDialog.__name__)

        self.user_state = user_state
        self.add_dialog(
            WaterfallDialog("WFDialog", [self.help_step, self.final_step]))
        self.add_dialog(TextPrompt(TextPrompt.__name__))

        self.initial_dialog_id = "WFDialog"
Пример #8
0
    def __init__(self):
        super().__init__(TangentDialog.__name__)

        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(
            WaterfallDialog(WaterfallDialog.__name__,
                            [self._step_1, self._step_2, self._end_step]))

        self.initial_dialog_id = WaterfallDialog.__name__
    def __init__(self):
        super().__init__("SimpleComponentDialog")

        self.add_dialog(TextPrompt("TextPrompt"))
        self.add_dialog(
            WaterfallDialog("WaterfallDialog", [self.prompt_for_name, self.final_step])
        )

        self.initial_dialog_id = "WaterfallDialog"
        self.end_reason = DialogReason.BeginCalled
Пример #10
0
 def __init__(self, id: str = None, prop: str = None):  # pylint: disable=unused-argument
     super().__init__(id or "SimpleComponentDialog")
     self.text_prompt = "TextPrompt"
     self.waterfall_dialog = "WaterfallDialog"
     self.add_dialog(TextPrompt(self.text_prompt))
     self.add_dialog(
         WaterfallDialog(self.waterfall_dialog, [
             self.prompt_for_name,
             self.final_step,
         ]))
     self.initial_dialog_id = self.waterfall_dialog
     self.end_reason = None
Пример #11
0
    def __init__(
        self,
        connection_name: str,
        user_state: UserState,
        logged_users: Dict[str, str],
    ):
        super(MainDialog, self).__init__(MainDialog.__name__, connection_name,
                                         user_state, logged_users)

        self.add_dialog(
            OAuthPrompt(
                OAuthPrompt.__name__,
                OAuthPromptSettings(
                    connection_name=connection_name,
                    text="Per favore effettua l'accesso a GitHub",
                    title="Sign In",
                    timeout=300000,
                ),
            ))

        self.add_dialog(TextPrompt(TextPrompt.__name__))

        self.add_dialog(
            AddPersonDialog(
                user_profile_accessor=self.user_profile_accessor,
                logged_users=logged_users,
            ))

        self.add_dialog(
            DeletePersonDialog(
                user_profile_accessor=self.user_profile_accessor,
                logged_users=logged_users,
            ))

        self.add_dialog(
            TestDialog(
                user_profile_accessor=self.user_profile_accessor,
                logged_users=logged_users,
            ))

        self.add_dialog(
            WaterfallDialog(
                "Main",
                [
                    self._init_step,
                    self._login_step,
                    self._command_step,
                ],
            ))

        self.initial_dialog_id = "Main"
    def __init__(self, dialog_id: str = None):
        super(RegistrationDialog, self).__init__(dialog_id or RegistrationDialog.__name__)

        
        self.add_dialog(TextPrompt(TextPrompt.__name__, RegistrationDialog.validate))
        self.add_dialog(
            WaterfallDialog(
                "WFDialog", [self.select_first,
                    self.select_second,
                    self.select_third,
                    self.register]
            )
        )

        self.initial_dialog_id = "WFDialog"
Пример #13
0
    def __init__(self, user_profile_accessor: StatePropertyAccessor,
                 logged_users: Dict[str, str]):
        super().__init__(DeletePersonDialog.__name__)

        self.add_dialog(AttachmentPrompt(AttachmentPrompt.__name__))
        self.add_dialog(ChoicePrompt(ChoicePrompt.__name__))
        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(
            WaterfallDialog('DeletePersonMainWF', [
                self._choose_person, self._confirm_choice, self._delete_person
            ]))

        self.logged_users = logged_users
        self.user_profile_accessor = user_profile_accessor

        self.initial_dialog_id = 'DeletePersonMainWF'
Пример #14
0
    def __init__(self, user_state: UserState):
        super(Dialog, self).__init__(Dialog.__name__)
        self.user_profile_accesor = user_state.create_property("UserProfile")

        self.add_dialog(
            WaterfallDialog(
                WaterfallDialog.__name__,
                [
                    self.options_step,
                ],
            )
        )
        self.add_dialog(ChoicePrompt("options_step"))
        self.add_dialog(ChoicePrompt(ChoicePrompt.__name__))
        self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__))
        self.initial_dialog_id = WaterfallDialog.__name__
        self.add_dialog(TextPrompt(TextPrompt.__name__))
Пример #15
0
    async def proceeds_through_waterfall(storage) -> bool:
        convo_state = ConversationState(storage)

        dialog_state = convo_state.create_property("dialogState")
        dialogs = DialogSet(dialog_state)

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

            await dialog_context.continue_dialog()
            if not turn_context.responded:
                await dialog_context.begin_dialog(WaterfallDialog.__name__)
            await convo_state.save_changes(turn_context)

        adapter = TestAdapter(exec_test)

        async def prompt_validator(prompt_context: PromptValidatorContext):
            result = prompt_context.recognized.value
            if len(result) > 3:
                succeeded_message = MessageFactory.text(
                    f"You got it at the {prompt_context.options.number_of_attempts}rd try!"
                )
                await prompt_context.context.send_activity(succeeded_message)
                return True

            reply = MessageFactory.text(
                f"Please send a name that is longer than 3 characters. {prompt_context.options.number_of_attempts}"
            )
            await prompt_context.context.send_activity(reply)
            return False

        async def step_1(
                step_context: WaterfallStepContext) -> DialogTurnStatus:
            assert isinstance(step_context.active_dialog.state["stepIndex"],
                              int)
            await step_context.context.send_activity("step1")
            return Dialog.end_of_turn

        async def step_2(step_context: WaterfallStepContext) -> None:
            assert isinstance(step_context.active_dialog.state["stepIndex"],
                              int)
            await step_context.prompt(
                TextPrompt.__name__,
                PromptOptions(
                    prompt=MessageFactory.text("Please type your name")),
            )

        async def step_3(
                step_context: WaterfallStepContext) -> DialogTurnStatus:
            assert isinstance(step_context.active_dialog.state["stepIndex"],
                              int)
            await step_context.context.send_activity("step3")
            return Dialog.end_of_turn

        steps = [step_1, step_2, step_3]

        dialogs.add(WaterfallDialog(WaterfallDialog.__name__, steps))

        dialogs.add(TextPrompt(TextPrompt.__name__, prompt_validator))

        step1 = await adapter.send("hello")
        step2 = await step1.assert_reply("step1")
        step3 = await step2.send("hello")
        step4 = await step3.assert_reply("Please type your name")  # None
        step5 = await step4.send("hi")
        step6 = await step5.assert_reply(
            "Please send a name that is longer than 3 characters. 0")
        step7 = await step6.send("hi")
        step8 = await step7.assert_reply(
            "Please send a name that is longer than 3 characters. 1")
        step9 = await step8.send("hi")
        step10 = await step9.assert_reply(
            "Please send a name that is longer than 3 characters. 2")
        step11 = await step10.send("Kyle")
        step12 = await step11.assert_reply("You got it at the 3rd try!")
        await step12.assert_reply("step3")

        return True