botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Restart and erase existing dialog

Open bluekite2000 opened this issue 10 years ago • 15 comments

After user A finishes (aka)

                    .AddRemainingFields()
                    .Message("Thanks {FullName}!")
                    .Build();

is there a way for me to delete the history so it goes back to Hi! I'm dummybot. Say "hi" if you'd like to chat? so user B can start from the beginning? Currently I have to refresh the server.

bluekite2000 avatar Apr 05 '16 21:04 bluekite2000

Are you sending messages to your bot using the emulator? If you change the UserId and ConversationId for the user B, your bot should start from a fresh state for the new user.

msft-shahins avatar Apr 05 '16 21:04 msft-shahins

@msft-shahins what about when I deploy it to https://webchat.botframework.com/bots/TestBot ? How can I delete existing dialogue and start a fresh session? Also what is the code to change the userid and conversationid? and where do I put it?

bluekite2000 avatar Apr 05 '16 22:04 bluekite2000

@bluekite2000 refresh of the webchat control will cause connector to generate a new conversationId and userId. When a message comes to your bot through connector, connector will manage the UserId and ConversationId for you. Also connector provides contextual data stores that your bot can use for state management. A new conversationId will be assigned to a session when a user starts a new conversation to your bot. You can test your bot by changing the conversationId and userId in the emulator. image

msft-shahins avatar Apr 05 '16 22:04 msft-shahins

@msft-shahins But this doesnt solve my problem. I have a checkin bot that checks in a line of users. So after A checks in, then B walks up to the kiosk and starts checking in. I need a way to programmatically restart a new session when A finishes and walks away.

bluekite2000 avatar Apr 05 '16 22:04 bluekite2000

@bluekite2000 Then it is your implementation that should determine the reset of the session when a new user talks to your bot. Bot builder uses message.BotPerUserInConversationData for dialog stack management and since connector isolates that storage for each user/conversation, your bot will start from its root dialog (fresh state) for each user. For your check in bot, you can have a global queue, add the result of each form dialog to the queue upon the completion.

msft-shahins avatar Apr 05 '16 22:04 msft-shahins

@msft-shahins Sorry can you clarify more on have a global queue, add the result of each form dialog to the queue upon the completion. ? How does this accomplish what I want ( reset session for next user to check in) ?

bluekite2000 avatar Apr 05 '16 22:04 bluekite2000

@bluekite2000 I am suggesting 'a way' to implement your check in bot. What I'm trying to say is that connector will assign a new conversationId to each new user talking to your bot and as a result your bot (if implemented correctly) will start from a fresh state for each user (unless you want to have some state sharing between each user).

msft-shahins avatar Apr 05 '16 22:04 msft-shahins

@msft-shahins I dont want any state sharing between user. I just dont know where I can find the code to assign a new conversationId to each new user

bluekite2000 avatar Apr 05 '16 23:04 bluekite2000

@bluekite2000 What I am trying to say is that connector will assign a new conversationId to the message for each new user based on the channel behavior. for example, on sms, each message from a new phone number (new user) will be assigned a new conversationId by connector and that conversationId will remain stable for that phone number over different messages.

msft-shahins avatar Apr 05 '16 23:04 msft-shahins

@msft-shahins so is there a way for me to programmatically reset the session for the next user (after user A) or not?

bluekite2000 avatar Apr 05 '16 23:04 bluekite2000

@bluekite2000 I am not sure what is the session that you are referring to. I highly recommend reading about tracking bot state in the connector's documentation. That might help you understand the state management that connector provides better.

msft-shahins avatar Apr 05 '16 23:04 msft-shahins

@msft-shahins I read it but it doesnt help. Here is my problem. I have a bot that checks people in. When person A checks in, my bot replies with "thanks" and he walks away. Currently I have to refresh the browser so B can check in. How can I programmatically refresh the browser (and give B a new session)?

bluekite2000 avatar Apr 05 '16 23:04 bluekite2000

@bluekite2000 the default web chat control doesn't provide a mechanism for you to refresh the session programmatically (It is not designed for the purpose you want to use it for. It is designed for websites loaded by different users on different machines and browsers). You can use direct line rest api to implement a web chat control that implement your behavior (refreshing the session by monitoring the responses from your bot on the client side).

msft-shahins avatar Apr 06 '16 00:04 msft-shahins

@bluekite2000 call /deleteprofile to reset the user session profile

rodzillarr avatar May 11 '16 00:05 rodzillarr

This does not reset dialog/form data!

MarekLani avatar Apr 26 '17 17:04 MarekLani