def __init__(self, nlu_recognizer: NLU, user_state: UserState):
        super(BookingRoomDialog, self).__init__(BookingRoomDialog.__name__)

        # Load the NLU module
        self._nlu_recognizer = nlu_recognizer

        # Load the RoomReservation class
        self.room_reservation_accessor = user_state.create_property(
            "RoomReservation")

        # Setup the waterfall dialog
        self.add_dialog(
            WaterfallDialog("WFBookingDialog", [
                self.people_step,
                self.duration_step,
                self.breakfast_step,
                self.summary_step,
            ]))

        # Append the prompts and custom prompts
        self.add_dialog(
            NumberPrompt("PeoplePrompt",
                         BookingRoomDialog.people_prompt_validator))
        self.add_dialog(
            NumberPrompt("DurationPrompt",
                         BookingRoomDialog.duration_prompt_validator))
        self.add_dialog(ConfirmPrompt("IsTakingBreakfastPrompt"))

        self.initial_dialog_id = "WFBookingDialog"
Beispiel #2
0
    def __init__(self, user_state: UserState):
        super(UserProfileDialog, self).__init__(UserProfileDialog.__name__)

        self.user_profile_accessor = user_state.create_property("UserProfile")

        self.add_dialog(
            WaterfallDialog(
                WaterfallDialog.__name__,
                [
                    self.transport_step,
                    self.name_step,
                    self.name_confirm_step,
                    self.age_step,
                    self.picture_step,
                    self.confirm_step,
                    self.summary_step,
                ],
            ))
        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(
            NumberPrompt(NumberPrompt.__name__,
                         UserProfileDialog.age_prompt_validator))
        self.add_dialog(ChoicePrompt(ChoicePrompt.__name__))
        self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__))
        self.add_dialog(
            AttachmentPrompt(AttachmentPrompt.__name__,
                             UserProfileDialog.picture_prompt_validator))

        self.initial_dialog_id = WaterfallDialog.__name__
    async def test_number_prompt_retry(self):
        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)

        adapter = TestAdapter(exec_test)

        convo_state = ConversationState(MemoryStorage())
        dialog_state = convo_state.create_property("dialogState")
        dialogs = DialogSet(dialog_state)
        number_prompt = NumberPrompt(dialog_id="NumberPrompt",
                                     validator=None,
                                     default_locale=Culture.English)
        dialogs.add(number_prompt)

        step1 = await adapter.send("hello")
        await step1.assert_reply("Enter a number.")
Beispiel #4
0
    def __init__(self, user_state: UserState):
        super(UserProfileDialog, self).__init__(UserProfileDialog.__name__)

        self.user_profile_accessor = user_state.create_property("UserProfile")

        self.add_dialog(
            WaterfallDialog(
                WaterfallDialog.__name__,
                [
                    self.first_step,
                    self.second_step,
                    self.third_step,
                    self.fourth_step,
                    self.fifth_step,
                    self.sixth_step,
                    self.seventh_step,
                    self.eighth_step,
                ],
            ))
        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(
            NumberPrompt(NumberPrompt.__name__,
                         UserProfileDialog.age_prompt_validator))
        self.add_dialog(ChoicePrompt(ChoicePrompt.__name__))
        self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__))
        self.add_dialog(
            AttachmentPrompt(AttachmentPrompt.__name__,
                             UserProfileDialog.picture_prompt_validator))

        self.initial_dialog_id = WaterfallDialog.__name__
Beispiel #5
0
    def __init__(self, dialog_id: str = None):
        super(ContactsSelectionDialog, self).__init__(
            dialog_id or ContactsSelectionDialog.__name__
        )

        self.add_dialog(
            WaterfallDialog(
                WaterfallDialog.__name__,
                [
                    self.confirm_confirmedcasecontact_step,
                    self.date_confirmedcasecontact_step,
                    self.confirm_suspectedcasecontact_step,
                    self.date_suspectedcasecontact_step,
                    self.contacts_dates_step]
            )
        )

        self.add_dialog(ChoicePrompt(ChoicePrompt.__name__))
        self.add_dialog(
            NumberPrompt(NumberPrompt.__name__)
        )
        self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__))
        self.add_dialog(DateTimePrompt(DateTimePrompt.__name__))

        self.initial_dialog_id = WaterfallDialog.__name__
    def __init__(self, dialog_id: str = None):
        super(InsuranceRenewalDialog,
              self).__init__(dialog_id or InsuranceRenewalDialog.__name__)

        self.add_dialog(
            TextPrompt(TextPrompt.__name__,
                       InsuranceRenewalDialog.policynumber_prompt_validator))
        self.add_dialog(
            TextPrompt(phone, InsuranceRenewalDialog.phone_prompt_validator))
        self.add_dialog(
            TextPrompt(date, InsuranceRenewalDialog.date_prompt_validator))
        self.add_dialog(
            NumberPrompt(NumberPrompt.__name__,
                         InsuranceRenewalDialog.phone_prompt_validator))
        self.add_dialog(
            WaterfallDialog(
                WaterfallDialog.__name__,
                [
                    self.check_query_policy_number,
                    self.check_query_mobile_number,
                    self.check_query_date_of_birth, self.summarize
                ],
            ))

        self.initial_dialog_id = WaterfallDialog.__name__
    async def test_number_prompt_defaults_to_en_us_culture(self):
        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="Enter a number.")
                )
                await dialog_context.prompt("NumberPrompt", options)

            elif results.status == DialogTurnStatus.Complete:
                number_result = float(results.result)
                await turn_context.send_activity(
                    MessageFactory.text(f"Bot received the number '{number_result}'.")
                )

            await conver_state.save_changes(turn_context)

        conver_state = ConversationState(MemoryStorage())
        dialog_state = conver_state.create_property("dialogState")
        dialogs = DialogSet(dialog_state)

        number_prompt = NumberPrompt("NumberPrompt")
        dialogs.add(number_prompt)

        adapter = TestAdapter(exec_test)

        step1 = await adapter.send("hello")
        step2 = await step1.assert_reply("Enter a number.")
        step3 = await step2.send("3.14")
        await step3.assert_reply("Bot received the number '3.14'.")
    def __init__(self, luis_recognizer: CalcoloImportoRecognizer,
                 calcolo_dialog: CalcoloDialog,
                 cancella_dialogo: CancellaDialogo):
        super(WaterfallQuery, self).__init__(WaterfallQuery.__name__)

        #self.user_profile_accessor = user_state.create_property("UserProfile")
        self._luis_recognizer = luis_recognizer
        self._calcolo_dialog_id = calcolo_dialog.id
        self._cancella_dialogo_id = cancella_dialogo.id

        self.add_dialog(cancella_dialogo)
        self.add_dialog(calcolo_dialog)

        self.add_dialog(
            WaterfallDialog(
                WaterfallDialog.__name__,
                [
                    self.domanda_step,
                    self.summary_step,
                ],
            ))

        self.add_dialog(TextPrompt(TextPrompt.__name__))
        #self.add_dialog(TextPrompt(TextPrompt.__name__, WaterfallQuery.insertCorrectdate))
        self.add_dialog(NumberPrompt(NumberPrompt.__name__))
        self.add_dialog(ChoicePrompt(ChoicePrompt.__name__))
        self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__))
        """self.add_dialog(
            AttachmentPrompt(
                AttachmentPrompt.__name__, WaterfallQuery.picture_prompt_validator
            )
        )"""

        self.initial_dialog_id = WaterfallDialog.__name__
Beispiel #9
0
 def __init__(self,conversation:ConversationState):
     self.con_statea = conversation
     self.state_prop = self.con_statea.create_property("dialog_set")
     self.dialog_set = DialogSet(self.state_prop)
     self.dialog_set.add(TextPrompt("text_prompt"))
     self.dialog_set.add(NumberPrompt("number_prompt"))
     self.dialog_set.add(WaterfallDialog("main_dialog",[self.GetUserName,self.GetMobileNumber,self.GetEmailId,self.Completed]))
    async def test_number_prompt_uses_locale_specified_in_activity(self):
        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="Enter a number.")
                )
                await dialog_context.prompt("NumberPrompt", options)

            elif results.status == DialogTurnStatus.Complete:
                number_result = float(results.result)
                self.assertEqual(3.14, number_result)

            await conver_state.save_changes(turn_context)

        conver_state = ConversationState(MemoryStorage())
        dialog_state = conver_state.create_property("dialogState")
        dialogs = DialogSet(dialog_state)

        number_prompt = NumberPrompt("NumberPrompt", None, None)
        dialogs.add(number_prompt)

        adapter = TestAdapter(exec_test)

        step1 = await adapter.send("hello")
        step2 = await step1.assert_reply("Enter a number.")
        await step2.send(
            Activity(type=ActivityTypes.message, text="3,14", locale=Culture.Spanish)
        )
Beispiel #11
0
 def __init__(self, conversation: ConversationState):
     self.con_statea = conversation
     self.state_prop = self.con_statea.create_property('dialog_set')
     self.dialog_set = DialogSet(self.state_prop)
     self.dialog_set.add(TextPrompt('text_prompt'))
     self.dialog_set.add(NumberPrompt('number_prompt', self.isValidNumber))
     self.dialog_set.add(WaterfallDialog('main_dialog',[self.GetUserName,self.GetUserNumber,self.GetUserEmailId,
                                                                              self.GetUserIntention,self.Completed]))
    async def test_number_prompt_validator(self):
        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:
                options = PromptOptions(
                    prompt=Activity(type=ActivityTypes.message, text="Enter a number."),
                    retry_prompt=Activity(
                        type=ActivityTypes.message,
                        text="You must enter a positive number less than 100.",
                    ),
                )
                await dialog_context.prompt("NumberPrompt", options)

            elif results.status == DialogTurnStatus.Complete:
                number_result = int(results.result)
                await turn_context.send_activity(
                    MessageFactory.text(f"Bot received the number '{number_result}'.")
                )

            await conver_state.save_changes(turn_context)

        # Create new ConversationState with MemoryStorage and register the state as middleware.
        conver_state = ConversationState(MemoryStorage())

        # Create a DialogState property, DialogSet and register the WaterfallDialog.
        dialog_state = conver_state.create_property("dialogState")

        dialogs = DialogSet(dialog_state)

        # Create and add number prompt to DialogSet.
        async def validator(prompt_context: PromptValidatorContext):
            result = prompt_context.recognized.value

            if 0 < result < 100:
                return True

            return False

        number_prompt = NumberPrompt(
            "NumberPrompt", validator, default_locale=Culture.English
        )
        dialogs.add(number_prompt)

        adapter = TestAdapter(exec_test)

        step1 = await adapter.send("hello")
        step2 = await step1.assert_reply("Enter a number.")
        step3 = await step2.send("150")
        step4 = await step3.assert_reply(
            "You must enter a positive number less than 100."
        )
        step5 = await step4.send("64")
        await step5.assert_reply("Bot received the number '64'.")
 def __init__(self, fanlysis: FuelAnalysis,
              conversation: ConversationState):
     self.con_statea = conversation
     self.fAnalysis = fanlysis
     self.state_prop = self.con_statea.create_property("dialog_set")
     self.dialog_set = DialogSet(self.state_prop)
     self.dialog_set.add(NumberPrompt("number_prompt",
                                      self.IsValidAreaCode))
     self.dialog_set.add(
         WaterfallDialog("main_dialog",
                         [self.GetIntro, self.GetCheapestCurrentPrice]))
Beispiel #14
0
 def __init__(self, conversation: ConversationState):
     self.con_statea = conversation
     self.state_prop = self.con_statea.create_property("dialog_set")
     self.dialog_set = DialogSet(self.state_prop)
     self.dialog_set.add(TextPrompt("text_prompt"))
     self.dialog_set.add(NumberPrompt("number_prompt"))
     self.dialog_set.add(ChoicePrompt(ChoicePrompt.__name__))
     self.dialog_set.add(
         WaterfallDialog("main_dialog", [
             self.GetUserName, self.DisplayChoiceList, self.GetProblem,
             self.waitAgent, self.Completed
         ]))
Beispiel #15
0
 def __init__(self, conversation: ConversationState):
     self.con_state = conversation
     self.state_prop = self.con_state.create_property("dialog_set")
     self.dialog_set = DialogSet(self.state_prop)
     self.dialog_set.add(TextPrompt("text_prompt"))
     self.dialog_set.add(
         NumberPrompt("number_prompt", self.is_valid_mobile_number))
     self.dialog_set.add(
         WaterfallDialog("main_dialog", [
             self.get_user_name, self.get_modile_number, self.get_email,
             self.complated
         ]))
    def __init__(self, dialog_id: str = None):
        super(UserIDResolverDialog,
              self).__init__(dialog_id or UserIDResolverDialog.__name__)

        self.add_dialog(
            NumberPrompt(NumberPrompt.__name__,
                         UserIDResolverDialog.user_id_prompt_validator))
        self.add_dialog(
            WaterfallDialog(WaterfallDialog.__name__ + "2",
                            [self.initial_step, self.final_step]))

        self.initial_dialog_id = WaterfallDialog.__name__ + "2"
Beispiel #17
0
 def __init__(self, conversation: ConversationState):
     self.con_statea = conversation
     self.state_prop = self.con_statea.create_property("dialog_set")
     self.dialog_set = DialogSet(self.state_prop)
     self.dialog_set.add(TextPrompt("text_prompt", self.isValidRepCommand))
     self.dialog_set.add(
         NumberPrompt("number_prompt", self.isValidRepCommand))
     # main Waterfall dialog flow to understand the sequence of dialogs
     self.dialog_set.add(
         WaterfallDialog(
             "main_dialog",
             [self.GetStartCommand, self.GetReporterId, self.Completed]))
Beispiel #18
0
    def __init__(self, dialog_id: str = None):
        super(CapcacityResolverDialog,
              self).__init__(dialog_id or CapcacityResolverDialog.__name__)

        self.add_dialog(
            NumberPrompt(NumberPrompt.__name__,
                         CapcacityResolverDialog.capcity_prompt_validator))
        self.add_dialog(
            WaterfallDialog(WaterfallDialog.__name__ + "2",
                            [self.initial_step, self.final_step]))

        self.initial_dialog_id = WaterfallDialog.__name__ + "2"
    async def test_number_uses_locale_specified_in_constructor(self):
        # Create new ConversationState with MemoryStorage and register the state as middleware.
        conver_state = ConversationState(MemoryStorage())

        # Create a DialogState property, DialogSet and register the WaterfallDialog.
        dialog_state = conver_state.create_property("dialogState")

        dialogs = DialogSet(dialog_state)

        # Create and add number prompt to DialogSet.
        number_prompt = NumberPrompt(
            "NumberPrompt", None, default_locale=Culture.Spanish
        )
        dialogs.add(number_prompt)

        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)

        adapter = TestAdapter(exec_test)

        test_flow = TestFlow(None, adapter)

        test_flow2 = await test_flow.send("Hello")
        test_flow3 = await test_flow2.assert_reply(
            "How much money is in your gaming account?"
        )
        test_flow4 = await test_flow3.send("I've got $1.200.555,42 in my account.")
        await test_flow4.assert_reply(
            "You say you have $1200555.42 in your gaming account."
        )
    def __init__(self, conversation: ConversationState, userstate: UserState,
                 cosdbStore: CosmosDbPartitionedStorage):
        self.con_statea = conversation
        self.userstate = userstate
        self.cosmodb = cosdbStore

        self.conprop = self.con_statea.create_property("constate")
        self.userprop = self.userstate.create_property("userstate")

        self.state_prop = self.con_statea.create_property("dialog_set")
        self.dialog_set = DialogSet(self.state_prop)
        self.dialog_set.add(TextPrompt("text_prompt"))
        self.dialog_set.add(NumberPrompt("number_prompt"))
        self.dialog_set.add(
            WaterfallDialog("main_dialog", [
                self.Hello, self.MoodCarousel, self.NegativeMoodCarousel,
                self.Completed
            ]))
    async def test_number_prompt(self):
        # Create new ConversationState with MemoryStorage and register the state as middleware.
        conver_state = ConversationState(MemoryStorage())

        # Create a DialogState property, DialogSet and register the WaterfallDialog.
        dialog_state = conver_state.create_property("dialogState")

        dialogs = DialogSet(dialog_state)

        # Create and add number prompt to DialogSet.
        number_prompt = NumberPrompt("NumberPrompt", None, "English")
        dialogs.add(number_prompt)

        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("Enter quantity of cable")
                    ),
                )
            else:
                if results.status == DialogTurnStatus.Complete:
                    number_result = results.result
                    await turn_context.send_activity(
                        MessageFactory.text(
                            f"You asked me for '{number_result}' meters of cable."
                        )
                    )

            await conver_state.save_changes(turn_context)

        adapter = TestAdapter(exec_test)

        test_flow = TestFlow(None, adapter)

        test_flow2 = await test_flow.send("Hello")
        test_flow3 = await test_flow2.assert_reply("Enter quantity of cable")
        test_flow4 = await test_flow3.send("Give me twenty meters of cable")
        await test_flow4.assert_reply("You asked me for '20' meters of cable.")
    def __init__(self, dialog_id: str = None):
        super(TopLevelDialog, self).__init__(dialog_id
                                             or TopLevelDialog.__name__)

        # Key name to store this dialogs state info in the StepContext
        self.USER_INFO = "value-userInfo"

        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(NumberPrompt(NumberPrompt.__name__))

        self.add_dialog(ReviewSelectionDialog(ReviewSelectionDialog.__name__))

        self.add_dialog(
            WaterfallDialog("WFDialog", [
                self.name_step, self.age_step, self.start_selection_step,
                self.acknowledgement_step
            ]))

        self.initial_dialog_id = "WFDialog"
Beispiel #23
0
    def __init__(self, dialog_id: str = None):
        super(TopLevelDialog, self).__init__(dialog_id
                                             or TopLevelDialog.__name__)

        # Key name to store this dialogs state info in the StepContext
        self.USER_INFO = "value-userInfo"

        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(NumberPrompt(NumberPrompt.__name__))

        choice = ChoicePrompt(ChoicePrompt.__name__)
        choice.recognizer_options = FindChoicesOptions(
            allow_partial_matches=True)
        self.add_dialog(choice)

        self.add_dialog(
            SymptomsSelectionDialog(SymptomsSelectionDialog.__name__))
        self.add_dialog(
            ContactsSelectionDialog(ContactsSelectionDialog.__name__))
        self.add_dialog(PersonalDataDialog(PersonalDataDialog.__name__))
        self.add_dialog(
            RiskCountrySelectionDialog(RiskCountrySelectionDialog.__name__))

        self.add_dialog(
            WaterfallDialog(
                "WFDialog",
                [
                    self.name_step,
                    self.age_step,
                    self.confirm_riskcountry_step,
                    self.start_riskcountry_selection_step,
                    self.start_symptom_selection_step,
                    self.temparature_step,
                    self.start_contacts_step,
                    self.job_claim_step,
                    self.job_type_step,
                    self.personal_data_step,
                    self.acknowledgement_step,
                ],
            ))

        self.initial_dialog_id = "WFDialog"
Beispiel #24
0
    def __init__(self, conversation: ConversationState):
        #get the state of conversation and store in a variable
        self.con_state = conversation

        #state property needs to be created from con state of conversation
        self.state_prop = self.con_state.create_property("dialog_set")
        #create dialogset - stateproperty is needed
        self.dialog_set = DialogSet(self.state_prop)
        #define dialog set, what all dialogs are going to be used
        self.dialog_set.add(TextPrompt("text_prompt"))
        self.dialog_set.add(
            NumberPrompt(
                "number_prompt",
                self.IsValidMobileNumber))  #Adding custom validation logic
        #define the steps, which question will be asked in sequence
        self.dialog_set.add(
            WaterfallDialog("main_dialog", [
                self.GetUserName, self.GetMobileNumber, self.GetEmailId,
                self.Completed
            ]))
    def __init__(self, dialog_id: str = None):
        super(CustomTopLevelDialog,
              self).__init__(dialog_id or CustomTopLevelDialog.__name__)
        self.add_dialog(NumberPrompt(NumberPrompt.__name__))
        self.add_dialog(Dialog001(Dialog001.__name__))
        self.add_dialog(Dialog002(Dialog002.__name__))
        self.add_dialog(Dialog003(Dialog003.__name__))
        self.add_dialog(Dialog004(Dialog004.__name__))
        self.add_dialog(Dialog005(Dialog005.__name__))
        self.add_dialog(Dialog006(Dialog006.__name__))
        self.add_dialog(Dialog007(Dialog007.__name__))
        self.add_dialog(Dialog008(Dialog008.__name__))
        self.add_dialog(TodoDialog(TodoDialog.__name__))

        self.add_dialog(
            WaterfallDialog("VPCenterDialog", [
                self.action_step,
                self.start_sub_step,
                self.loop_step,
            ]))

        self.initial_dialog_id = "VPCenterDialog"
    async def test_float_number_prompt(self):
        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:
                options = PromptOptions(
                    prompt=Activity(type=ActivityTypes.message, text="Enter a number.")
                )
                await dialog_context.prompt("NumberPrompt", options)

            elif results.status == DialogTurnStatus.Complete:
                number_result = float(results.result)
                await turn_context.send_activity(
                    MessageFactory.text(f"Bot received the number '{number_result}'.")
                )

            await conver_state.save_changes(turn_context)

        # Create new ConversationState with MemoryStorage and register the state as middleware.
        conver_state = ConversationState(MemoryStorage())

        # Create a DialogState property, DialogSet and register the WaterfallDialog.
        dialog_state = conver_state.create_property("dialogState")

        dialogs = DialogSet(dialog_state)

        # Create and add number prompt to DialogSet.
        number_prompt = NumberPrompt(
            "NumberPrompt", validator=None, default_locale=Culture.English
        )
        dialogs.add(number_prompt)

        adapter = TestAdapter(exec_test)

        step1 = await adapter.send("hello")
        step2 = await step1.assert_reply("Enter a number.")
        step3 = await step2.send("3.14")
        await step3.assert_reply("Bot received the number '3.14'.")
Beispiel #27
0
    def __init__(self, dialog_id: str = None):
        super(PersonalDataDialog,
              self).__init__(dialog_id or PersonalDataDialog.__name__)

        # Key name to store this dialogs state info in the StepContext
        self.PERSONAL_DATA = "value-personalData"

        self.add_dialog(
            WaterfallDialog(WaterfallDialog.__name__, [
                self.first_name_step, self.family_name_step, self.gender_step,
                self.street_step, self.zipcode_step, self.city_step,
                self.telephone_step, self.email_step, self.birthday_step,
                self.final_step
            ]))

        self.add_dialog(ChoicePrompt(ChoicePrompt.__name__))
        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(NumberPrompt(NumberPrompt.__name__))
        self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__))
        self.add_dialog(DateTimePrompt(DateTimePrompt.__name__))

        self.initial_dialog_id = WaterfallDialog.__name__
    def __init__(self, dialog_id: str = None):
        super(WaterfallText, self).__init__(dialog_id
                                            or WaterfallText.__name__)

        self.add_dialog(
            WaterfallDialog(
                WaterfallDialog.__name__,
                [
                    self.fatturatestuale_step,
                    self.date_step,
                    self.confirm_step,
                    self.insertdata_step,
                    self.summary_step,
                ],
            ))
        #self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(
            TextPrompt(TextPrompt.__name__, WaterfallText.insertCorrectdate))
        self.add_dialog(NumberPrompt(NumberPrompt.__name__))
        self.add_dialog(ChoicePrompt(ChoicePrompt.__name__))
        self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__))

        self.initial_dialog_id = WaterfallDialog.__name__
    def __init__(self, dialog_id: str = None):
        super(WaterfallPhoto, self).__init__(dialog_id
                                             or WaterfallPhoto.__name__)

        #self.user_profile_accessor = user_state.create_property("UserProfile")
        self.add_dialog(
            WaterfallDialog(
                WaterfallDialog.__name__,
                [
                    self.picture_step,
                    self.confirm_step,
                    self.evaluate_data_step,
                ],
            ))
        self.add_dialog(TextPrompt(TextPrompt.__name__))
        #self.add_dialog(TextPrompt(TextPrompt.__name__, WaterfallQuery.insertCorrectdate))
        self.add_dialog(NumberPrompt(NumberPrompt.__name__))
        self.add_dialog(ChoicePrompt(ChoicePrompt.__name__))
        self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__))
        self.add_dialog(
            AttachmentPrompt(AttachmentPrompt.__name__,
                             WaterfallPhoto.picture_prompt_validator))

        self.initial_dialog_id = WaterfallDialog.__name__
Beispiel #30
0
 def test_empty_should_fail(self):
     empty_id = ''
     self.assertRaises(TypeError, lambda: NumberPrompt(empty_id))