Search code examples
pythonpython-3.xbotframeworkchatbotsample

How to finish the bot-authentication dialog


I am working with the bot-auth sample and after having the user logged in I need to be able to interact with the user, in my case I would like to start with an echo. I can't find a way to end the dialog and for the bot to start answering the user. Could you guide me with an example or ideas? Thanks

I wouldn't need to show the token, so at this point it would be enough for me to finish here and start interacting with the user

main_dialog.py

async def login_step(self, step_context: WaterfallStepContext) -> DialogTurnResult:
    # Get the token from the previous step. Note that we could also have gotten the
    # token directly from the prompt itself. There is an example of this in the next method.
    if step_context.result:
        await step_context.context.send_activity("You are now logged in.")
        return await step_context.prompt(
            ConfirmPrompt.__name__,
            PromptOptions(
                prompt=MessageFactory.text("Would you like to view your token?")
            ),
        )

    await step_context.context.send_activity(
        "Login was not successful please try again."
    )
    return await step_context.end_dialog()

Solution

  • I could achieve my goal, which was once finished the login of the user to start, e.g, using a echo_bot or qna_bot. The problem is that I couldn't get out of the login-show token dialog loop. The solution "I found" is to create a user_state.create_property() in main_dialog.py and access properties defined get(turn_context) in dialog_bot.py. With this I was able to leave the dialogue.