diff --git a/code/backend/bots/assistant_bot.py b/code/backend/bots/assistant_bot.py index 6f7921b..befe05d 100644 --- a/code/backend/bots/assistant_bot.py +++ b/code/backend/bots/assistant_bot.py @@ -10,6 +10,7 @@ TurnContext, UserState, ) +from botbuilder.dialogs import Dialog from botbuilder.schema import ( ActionTypes, Attachment, @@ -18,6 +19,7 @@ SuggestedActions, ) from core.config import settings +from dialogs.dialog_helper import DialogHelper from llm.assisstant import assistant_handler from models.assistant_bot_models import ConversationData, FileInfo, UserData from models.assistant_models import AttachmentResult @@ -29,7 +31,10 @@ class AssistantBot(ActivityHandler): def __init__( - self, conversation_state: ConversationState, user_state: UserState + self, + conversation_state: ConversationState, + user_state: UserState, + dialog: Dialog, ) -> None: """Initailizes the Bot with states. @@ -46,6 +51,7 @@ def __init__( "Missing user state parameter. 'user_state' is required but None was given." ) + self.dialog = dialog self.conversation_state = conversation_state self.user_state = user_state self.conversation_state_accessor = self.conversation_state.create_property( @@ -79,6 +85,7 @@ async def on_members_added_activity( "Hello and welcome! I am your personal joke assistant." ) await turn_context.send_activity(welcome_message) + await turn_context.send_activity("Type any message to get logged in.") # Respond with suggested actions suggested_topics_message = ( @@ -136,7 +143,14 @@ async def on_message_activity(self, turn_context: TurnContext) -> None: turn_context (TurnContext): The turn context. RETURNS (None): No return value. """ - logger.info(f"Received input from user.") + logger.info(f"Received input from user. Starting dialog to handle login.") + await DialogHelper.run_dialog( + dialog=self.dialog, + turn_context=turn_context, + accessor=self.conversation_state_accessor, + ) + + logger.info(f"Handle message from user.") if ( turn_context.activity.attachments and len(turn_context.activity.attachments) > 0 diff --git a/code/backend/bots/auth_bot.py b/code/backend/bots/auth_bot.py index 3fc3eb1..c92e691 100644 --- a/code/backend/bots/auth_bot.py +++ b/code/backend/bots/auth_bot.py @@ -38,7 +38,6 @@ async def on_members_added_activity( await super(AuthBot, self).on_members_added_activity( members_added, turn_context ) - await turn_context.send_activity("Type any message to get logged in.") async def on_turn(self, turn_context: TurnContext) -> None: """Called by the adapter to handle activities. diff --git a/code/backend/dialogs/login_dialog.py b/code/backend/dialogs/login_dialog.py index 42a342a..6574eff 100644 --- a/code/backend/dialogs/login_dialog.py +++ b/code/backend/dialogs/login_dialog.py @@ -22,6 +22,7 @@ def __init__(self, connection_name: str) -> None: super(LoginDialog, self).__init__( dialog_id=LoginDialog.__name__, connection_name=connection_name ) + self.dialog_id = "WaterfallDialog" self.add_dialog( dialog=OAuthPrompt( @@ -43,7 +44,7 @@ def __init__(self, connection_name: str) -> None: self.add_dialog( dialog=WaterfallDialog( - dialog_id="WaterfallDialog", + dialog_id=self.dialog_id, steps=[ self.prompt_step, self.login_step, @@ -51,10 +52,10 @@ def __init__(self, connection_name: str) -> None: ) ) - async def on_begin_dialog( - self, inner_dc: DialogContext, options: object - ) -> DialogTurnResult: - return await super().on_begin_dialog(inner_dc=inner_dc, options=options) + # async def on_begin_dialog( + # self, inner_dc: DialogContext, options: object + # ) -> DialogTurnResult: + # return await super().on_begin_dialog(inner_dc=inner_dc, options=options) async def prompt_step(self, step_context: WaterfallStepContext) -> DialogTurnResult: """Handles the prompt step of the login dialog.