Example #1
0
    def __init__(
            self,
            configuration: dict,
            dialog_id: str = None,
            telemetry_client: BotTelemetryClient = NullTelemetryClient(),
    ):
        super(MainDialog, self).__init__(dialog_id or MainDialog.__name__)

        self._configuration = configuration
        self.telemetry_client = telemetry_client

        text_prompt = TextPrompt(TextPrompt.__name__)
        text_prompt.telemetry_client = self.telemetry_client

        booking_dialog = BookingDialog(telemetry_client=self._telemetry_client)
        booking_dialog.telemetry_client = self.telemetry_client

        wf_dialog = WaterfallDialog(
            "WFDialog", [self.intro_step, self.act_step, self.final_step])
        wf_dialog.telemetry_client = self.telemetry_client

        self.add_dialog(text_prompt)
        self.add_dialog(booking_dialog)
        self.add_dialog(wf_dialog)

        self.initial_dialog_id = "WFDialog"
Example #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'
Example #3
0
 def test_none_telemetry_client(self):
     # arrange
     dialog = WaterfallDialog("myId")
     # act
     dialog.telemetry_client = None
     # assert
     self.assertEqual(type(dialog.telemetry_client), NullTelemetryClient)
    def __init__(
            self,
            dialog_id: str = None,
            telemetry_client: BotTelemetryClient = NullTelemetryClient(),
    ):
        super(BookingDialog,
              self).__init__(dialog_id or BookingDialog.__name__,
                             telemetry_client)
        self.telemetry_client = telemetry_client
        text_prompt = TextPrompt(TextPrompt.__name__)
        text_prompt.telemetry_client = telemetry_client

        waterfall_dialog = WaterfallDialog(
            WaterfallDialog.__name__,
            [
                self.destination_step,
                self.origin_step,
                self.travel_date_step,
                # self.confirm_step,
                self.final_step,
            ],
        )
        waterfall_dialog.telemetry_client = telemetry_client

        self.add_dialog(text_prompt)
        # self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__))
        self.add_dialog(
            DateResolverDialog(DateResolverDialog.__name__,
                               self.telemetry_client))
        self.add_dialog(waterfall_dialog)

        self.initial_dialog_id = WaterfallDialog.__name__
Example #5
0
    async def test_cancelling_waterfall_telemetry(self):
        # Arrange
        dialog_id = "waterfall"
        index = 0
        guid = "(guid)"

        async def my_waterfall_step(step) -> DialogTurnResult:
            await step.context.send_activity("step1 response")
            return Dialog.end_of_turn

        dialog = WaterfallDialog(dialog_id, [my_waterfall_step])

        telemetry_client = create_autospec(NullTelemetryClient)
        dialog.telemetry_client = telemetry_client

        dialog_instance = DialogInstance()
        dialog_instance.id = dialog_id
        dialog_instance.state = {"instanceId": guid, "stepIndex": index}

        # Act
        await dialog.end_dialog(
            TurnContext(TestAdapter(), Activity()),
            dialog_instance,
            DialogReason.CancelCalled,
        )

        # Assert
        telemetry_props = telemetry_client.track_event.call_args_list[0][0][1]

        self.assertEqual(3, len(telemetry_props))
        self.assertEqual(dialog_id, telemetry_props["DialogId"])
        self.assertEqual(my_waterfall_step.__qualname__,
                         telemetry_props["StepName"])
        self.assertEqual(guid, telemetry_props["InstanceId"])
        telemetry_client.track_event.assert_called_once()
Example #6
0
    def __init__(
        self,
        luis_recognizer: FlightBookingRecognizer,
        booking_dialog: BookingDialog,
        telemetry_client: BotTelemetryClient = None,
    ):
        super(MainDialog, self).__init__(MainDialog.__name__)
        self.telemetry_client = telemetry_client or NullTelemetryClient()

        text_prompt = TextPrompt(TextPrompt.__name__)
        text_prompt.telemetry_client = self.telemetry_client

        booking_dialog.telemetry_client = self.telemetry_client

        wf_dialog = WaterfallDialog(
            "WFDialog", [self.intro_step, self.act_step, self.final_step])
        wf_dialog.telemetry_client = self.telemetry_client

        self._luis_recognizer = luis_recognizer
        self._booking_dialog_id = booking_dialog.id

        self.add_dialog(text_prompt)
        self.add_dialog(booking_dialog)
        self.add_dialog(wf_dialog)

        self.initial_dialog_id = "WFDialog"
    def __init__(self, connection_name: str,  luis_recognizer: BotRecognizer, conversation_state):
        super(MainDialog, self).__init__(MainDialog.__name__)
        self.connection_name=connection_name
        
        self._luis_recognizer = luis_recognizer
        self.findbook_dialog_id=findbook.id
        self.registration_dialog_id=registration_dialog.id
        self.wishlist_dialog_id=wishlist_dialog.id
        self.suggest_dialog_id=suggest_dialog.id
    
        wishlist_dialog.set_recognizer(luis_recognizer)

        self.add_dialog(
            OAuthPrompt(
                OAuthPrompt.__name__,
                OAuthPromptSettings(
                    connection_name=connection_name,
                    text="Accedi",
                    title="Sign In",
                    timeout=300000,
                ),
            )
        )

        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__))
        self.add_dialog(
            WaterfallDialog(
                "WFDialog", 
                [
                 self.menu_step, 
                 self.options_step,
                 self.final_step, 
                 self.loop_step]
            )
        )
        self.add_dialog(findbook)
        self.add_dialog(registration_dialog)
        self.add_dialog(wishlist_dialog)
        self.add_dialog(suggest_dialog)
        

        self.add_dialog(
            WaterfallDialog(
                "WFDialogLogin",
                [
                    self.prompt_step,
                    self.login_step,
                    self.continue_step
                ]
            )
        )

        self.initial_dialog_id = "WFDialogLogin"
        self.conversation_state=conversation_state
    def __init__(self, dialog_id: str = None):
        super(RiskCountrySelectionDialog,
              self).__init__(dialog_id or RiskCountrySelectionDialog.__name__)

        self.RISK_COUNTRIES_SELECTED = "value-symptomsSelected"
        self.RISK_COUNTRIES_DATES = "value-symptomsDates"
        self.DONE_OPTION = "**Keine**"

        self.riskcountry_options = [
            "Ägypten",
            "Hubei (China)",
            "Region Grand Est (Frankreich)",
            "Iran",
            "Italien",
            "Tirol (Österreich)",
            "Madrid (Spanien)",
            "Gyeongsangbuk-do (Südkorea)",
            "Kalifornien, Washington oder New York (USA)",
        ]
        choice = ChoicePrompt(ChoicePrompt.__name__)
        choice.recognizer_options = FindChoicesOptions(
            allow_partial_matches=True)
        self.add_dialog(choice)
        self.add_dialog(
            WaterfallDialog(
                WaterfallDialog.__name__,
                [self.selection_step, self.loop_step, self.save_step]))

        self.add_dialog(DateTimePrompt(DateTimePrompt.__name__))

        self.initial_dialog_id = WaterfallDialog.__name__
Example #9
0
    def __init__(self,
                 azure_connection_name: str = None,
                 gcp_connection_name: str = None):
        super(MainDialog, self).__init__(MainDialog.__name__)

        if not azure_connection_name and not gcp_connection_name:
            raise ValueError(
                f"Felix must be provided with at least 1 connection name (GCP/Azure)"
            )

        self.azure_dialog = None
        self.gcp_dialog = None

        # add the dialogs
        if azure_connection_name:
            self.azure_dialog = AzureDialog(
                connection_name=azure_connection_name)
            self.add_dialog(self.azure_dialog)

        if gcp_connection_name:
            self.gcp_dialog = GcpDialog(connection_name=gcp_connection_name)
            self.add_dialog(self.gcp_dialog)

        self.add_dialog(ChoicePrompt(ChoicePrompt.__name__))
        self.add_dialog(
            WaterfallDialog("MainDialog", [
                self.choose_cloud_step,
                self.begin_cloud_dialog_step,
            ]))

        self.initial_dialog_id = "MainDialog"  # Indicating with what dialog to start
    def __init__(self, connection_name: str):
        super().__init__(SsoSignInDialog.__name__)

        self.add_dialog(
            OAuthPrompt(
                OAuthPrompt.__name__,
                OAuthPromptSettings(
                    connection_name=connection_name,
                    text=
                    f"Sign in to the host bot using AAD for SSO and connection {connection_name}",
                    title="Sign In",
                    timeout=60000,
                ),
            ))

        self.add_dialog(
            WaterfallDialog(
                WaterfallDialog.__name__,
                [
                    self.signin_step,
                    self.display_token,
                ],
            ))

        self.initial_dialog_id = WaterfallDialog.__name__
Example #11
0
    def __init__(self, luis_recognizer: FlightBookingRecognizer,
                 lehoi_dialog: LehoiDialog, diadiem_dialog: DiadiemDialog,
                 dantoc_dialog: DantocDialog,
                 goiylehoi_dialog: GoiyLehoiDialog,
                 goiylehoi2_dialog: GoiyLehoiDialog2):
        super(MainDialog, self).__init__(MainDialog.__name__)

        self._luis_recognizer = luis_recognizer
        self._lehoi_dialog_id = lehoi_dialog.id
        self._diadiem_dialog_id = diadiem_dialog.id
        self._dantoc_dialog_id = dantoc_dialog.id
        self._goiylehoi_dialog_id = goiylehoi_dialog.id
        self._goiylehoi2_dialog_id = goiylehoi2_dialog.id

        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(lehoi_dialog)
        self.add_dialog(diadiem_dialog)
        self.add_dialog(dantoc_dialog)
        self.add_dialog(goiylehoi_dialog)
        self.add_dialog(goiylehoi2_dialog)
        self.add_dialog(
            WaterfallDialog("WFDialog", [
                self.intro_step, self.option_step, self.act_step,
                self.final_step
            ]))

        self.initial_dialog_id = "WFDialog"
    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__
Example #13
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]))
Example #14
0
    def __init__(self, user_state: UserState, conversation_state: ConversationState, informer: ExchangeRatesInformer):
        # Validate input params
        if conversation_state is None:
            raise TypeError(
                f"[{MainDialog.__name__}]: Missing parameter. conversation_state is required but None was given"
            )
        if user_state is None:
            raise TypeError(
                f"[{MainDialog.__name__}]: Missing parameter. user_state is required but None was given"
            )

        super(MainDialog, self).__init__(MainDialog.__name__)
        self.user_state = user_state
        self.conversation_state = conversation_state
        self.user_preferences_accessor = self.user_state.create_property("user_preferences")

        # Setup msg recognizers and responders
        self.msg_recognizers: List[BaseMsgRecognizer] = self.__create_msg_recognizers()
        self.msg_responders: List[BaseMsgResponder] = self.__create_msg_responders(informer)

        # Setup dialogs
        self.user_preferences_dialog_id = 'welcome_user_prefs'
        self.add_dialog(UserPreferencesDialog(self.user_preferences_dialog_id, user_state))

        self.add_dialog(
            WaterfallDialog(
                MainDialog.WATERFALL_DIALOG_ID,
                [
                    self.initial_step,
                    self.final_step
                ],
            )
        )
        self.initial_dialog_id = MainDialog.WATERFALL_DIALOG_ID
    def __init__(
        self,
        configuration: DefaultConfig,
        conversation_state: ConversationState,
        conversation_id_factory: SkillConversationIdFactory,
        skill_client: SkillHttpClient,
        continuation_parameters_store: Dict,
    ):
        super().__init__(ActivityRouterDialog.__name__)

        self.add_dialog(CardDialog(configuration))
        self.add_dialog(MessageWithAttachmentDialog(configuration))

        self.add_dialog(
            WaitForProactiveDialog(configuration,
                                   continuation_parameters_store))

        self.add_dialog(AuthDialog(configuration))
        self.add_dialog(SsoSkillDialog(configuration))
        self.add_dialog(FileUploadDialog())
        self.add_dialog(DeleteDialog())
        self.add_dialog(UpdateDialog())

        self.add_dialog(
            self.create_echo_skill_dialog(configuration, conversation_state,
                                          conversation_id_factory,
                                          skill_client))
        self.add_dialog(
            WaterfallDialog(WaterfallDialog.__name__, [self.process_activity]))

        self.initial_dialog_id = WaterfallDialog.__name__
Example #16
0
 def __init__(self, user_state: UserState):
     super(MainDialog, self).__init__(MainDialog.__name__)
     self.user_state = user_state
     self.add_dialog(TopLevelDialog(TopLevelDialog.__name__))
     self.add_dialog(
         WaterfallDialog("WFDialog", [self.initial_step, self.final_step]))
     self.initial_dialog_id = "WFDialog"
Example #17
0
    def __init__(self, connection_name: str):
        super(AzureDialog, self).__init__(AzureDialog.__name__,
                                          connection_name)

        self.azclient = AzureClient()
        self.data = AzureDialogData()

        self.add_dialog(
            OAuthPrompt(
                "AzureAuthPrompt",
                OAuthPromptSettings(
                    connection_name=connection_name,
                    text="Please Sign In",
                    title="Sign In",
                    timeout=300000,
                ),
            ))
        self.add_dialog(ChoicePrompt(ChoicePrompt.__name__))
        self.add_dialog(
            WaterfallDialog(
                "AzureDialog",
                [
                    self.get_token_step,
                    self.choose_subscription_step,
                    self.list_running_vms_step,
                ],
            ))

        self.initial_dialog_id = "AzureDialog"
Example #18
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__
Example #19
0
    def __init__(self, connection_name: str):
        super(MainDialog, self).__init__(MainDialog.__name__, connection_name)

        self.add_dialog(
            OAuthPrompt(
                OAuthPrompt.__name__,
                OAuthPromptSettings(
                    connection_name=connection_name,
                    text="Please Sign In",
                    title="Sign In",
                    timeout=300000,
                ),
            ))

        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__))

        self.add_dialog(
            WaterfallDialog(
                "WFDialog",
                [
                    self.prompt_step,
                    self.login_step,
                    self.command_step,
                    self.process_step,
                ],
            ))

        self.initial_dialog_id = "WFDialog"
Example #20
0
    def __init__(self, connection_name: str):
        super(GcpDialog, self).__init__(GcpDialog.__name__, connection_name)

        self.gclient = GcpClient()
        self.data = GcpDialogData()

        self.add_dialog(
            OAuthPrompt(
                "GcpAuthPrompt",
                OAuthPromptSettings(
                    connection_name=connection_name,
                    text="Please Sign In",
                    title="Sign In",
                    timeout=300000,
                ),
            )
        )
        self.add_dialog(
            WaterfallDialog(
                "GcpDialog",
                [
                    self.get_token_step,
                    self.choose_all_or_specific_project,
                    self.choose_specific_project_step,
                    self.list_running_instances_step,
                ],
            )
        )

        self.initial_dialog_id = "GcpDialog"
    def __init__(self, user_state: UserState, storage: object):
        super(CreateDeliveryDialog, self).__init__(CreateDeliveryDialog.__name__)

        self.user_state = user_state
        self.did_show_entry_msg = False
        self.storage = storage

        self.add_dialog(ChoicePrompt(ChoicePrompt.__name__))
        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(DateTimePrompt(DateTimePrompt.__name__))
        self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__))
        self.add_dialog(
            WaterfallDialog(
                Keys.WATER_FALL_DIALOG_ID.value,
                [
                    self.item_step,
                    self.destination_step,
                    self.time_step,
                    self.confirm_step,
                    self.acknowledgement_step
                ],
            )
        )

        self.initial_dialog_id = Keys.WATER_FALL_DIALOG_ID.value
Example #22
0
    def __init__(self, user_state: UserState,
                 luis_recognizer: InsuranceQueryRecognizer,
                 insurance_renewal_dialog: InsuranceRenewalDialog,
                 reservation_booking_dialog: ReservationBookingDialog):
        super(MainDialog, self).__init__(MainDialog.__name__)

        self.qna_maker = QnAMaker(
            QnAMakerEndpoint(knowledge_base_id=config.QNA_KNOWLEDGEBASE_ID,
                             endpoint_key=config.QNA_ENDPOINT_KEY,
                             host=config.QNA_ENDPOINT_HOST))

        self.user_profile_accessor = user_state.create_property("UserData")
        self.insurance_renewal_dialog_id = insurance_renewal_dialog.id
        self.reservation_booking_dialog_id = reservation_booking_dialog.id
        self._luis_recognizer = luis_recognizer
        self.user_state = user_state
        self.add_dialog(TextPrompt(TextPrompt.__name__))
        self.add_dialog(ChoicePrompt(INS_PROMPT_OPTIONS))
        self.add_dialog(insurance_renewal_dialog)
        self.add_dialog(reservation_booking_dialog)
        self.add_dialog(
            WaterfallDialog("WFDialog", [
                self.intro_step, self.name_process_step, self.luis_query_step,
                self.closing_step
            ]))
        self.initial_dialog_id = "WFDialog"
    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__
Example #24
0
    def __init__(self, client: GraphClient, dialog_id: str):
        """inits a HKDialog instance

        Args:
            client (GraphClient): MS Graph client instance associated with this dialog. Used to perform all calls to the Graph API
            dialog_id (str): a unique name identifying specific dialog.
        """
        super().__init__(dialog_id or HKDialog.__name__)

        self.DONE_OPTION = 'завершить'
        self.LAST_OPTION = 'свежий'
        self.SELECTED_CHANNEL = 'value-selectedChannel'
        self.DRIVE_ID = "b!iRCqps0M3E6-aQPU3EqrwtQWpaUslmNGiehCSqvs_PgkFFzTCYK_Sa7Y0KpehzLj"
        self.SITE_ID = "tikkurila.sharepoint.com,a6aa1089-0ccd-4edc-be69-03d4dc4aabc2,a5a516d4-962c-4663-89e8-424aabecfcf8"
        self.client = client
        self._query = ""
        self._max_period = ""

        self.options_list = {
            "Деко": "Deco",
            "Индастри": "Industry",
            self.DONE_OPTION: self.DONE_OPTION,
        }

        self.add_dialog(ChoicePrompt('channels'))
        self.add_dialog(TextPrompt('dates', HKDialog.query_validator))
        self.add_dialog(
            WaterfallDialog("WFDiag", [
                self.channel_step,
                self.dates_step,
                self.final_step,
            ]))

        self.initial_dialog_id = "WFDiag"
    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__
    def __init__(self, client: GraphClient, dialog_id: str = None):
        """inits a PersonDialog instance

        Args:
            client (GraphClient): MS Graph client instance associated with this dialog. Used to perform all calls to the Graph API
            dialog_id (str): a unique name identifying specific dialog.
        """
        super().__init__(dialog_id or PersonDialog.__name__)

        self.DONE_OPTION = "завершить"
        self.EXCEL_LINK = ""
        self.SITE_ID = "tikkurila.sharepoint.com,a6aa1089-0ccd-4edc-be69-03d4dc4aabc2,a5a516d4-962c-4663-89e8-424aabecfcf8"
        self.DRIVE_ID = "b!iRCqps0M3E6-aQPU3EqrwtQWpaUslmNGiehCSqvs_PjR9APmWaAIRJ2s7cN4zjqu"

        self.selected_keys = []
        self.client = client
        self.json_path = None

        self.options_list = ["ФАО", "Бухгалтерия", self.DONE_OPTION]

        self.add_dialog(ChoicePrompt('level1'))
        self.add_dialog(ChoicePrompt('level2'))
        self.add_dialog(ChoicePrompt('level3'))
        self.add_dialog(ChoicePrompt('level4'))

        self.add_dialog(
            WaterfallDialog("WFDiag", [
                self.dep_step,
                self.type_step,
                self.subtype_step,
                self.lvl4_step,
                self.final_step,
            ]))

        self.initial_dialog_id = "WFDiag"
    def __init__(self, user_state: UserState, client: GraphClient,
                 dialog_id: str):
        """inits an AutoreplyDialog instance

        Args:
            user_state (UserState): user state storage object
            client (GraphClient): MS Graph client instance associated with this dialog. Used to perform all calls to the Graph API
            dialog_id (str): a unique name identifying specific dialog.
        """
        super().__init__(dialog_id or AutoreplyDialog.__name__)

        self.DONE_OPTION = 'завершить'
        self.CARD_PATH = ["cards_templates", "Autoreply_card"]
        self.client = client
        self.user_state = user_state
        self.accessor = self.user_state.create_property("UserProfile")
        self.today = datetime.date(datetime.today())

        # add validator if it flies
        self.add_dialog(TextPrompt("fake", AutoreplyDialog.validation_wrapper))
        self.add_dialog(
            WaterfallDialog("WFDiag", [
                self.card_step,
                self.final_step,
            ]))
        self.initial_dialog_id = "WFDiag"
    def __init__(
        self, connection_name: str
    ):
        super(MainDialog, self).__init__(MainDialog.__name__, connection_name)

        self.add_dialog(
            OAuthPrompt(
                OAuthPrompt.__name__,
                OAuthPromptSettings(
                    connection_name=connection_name,
                    text="Please Sign In",
                    title="Sign In",
                    timeout=300000
                )
            )
        )

        self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__))

        self.add_dialog(
            WaterfallDialog(
                "WFDialog", [
                    self.prompt_step,
                    self.login_step,
                    self.display_token_phase1,
                    self.display_token_phase2
                ]
            )
        )

        self.initial_dialog_id = "WFDialog"
Example #29
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_two_turn_waterfall_dialog(self):
        async def step1(step: WaterfallStepContext) -> DialogTurnResult:
            await step.context.send_activity("hello")
            await step.context.send_activity(Activity(type="typing"))
            return await step.next(result=None)

        async def step2(step: WaterfallStepContext) -> DialogTurnResult:
            await step.context.send_activity("hello 2")
            return await step.end_dialog()

        dialog = WaterfallDialog("waterfall", [step1, step2])
        client = DialogTestClient(
            "test",
            dialog,
            initial_dialog_options=None,
            middlewares=[DialogTestLogger()],
        )

        reply = await client.send_activity("hello")
        self.assertEqual("hello", reply.text)

        reply = client.get_next_reply()
        self.assertEqual("typing", reply.type)

        reply = client.get_next_reply()
        self.assertEqual("hello 2", reply.text)
        self.assertEqual(DialogTurnStatus.Complete,
                         client.dialog_turn_result.status)