How can I clear BotUserSession from web application?
Scenario -
I am logged into my web application where my bot is integrated.
When I access my bot, bot user session is created and with each user utterance, I am adding some data to BotUserSession object so that I can use it later in the same user session conversation.
Now if I log out of my web application then ideally, bot user session should also be cleared as the session for logged in user is closed.
Is there any way to tell bot to close the current user session?
Ideally, the botUsersession is persisted till 15mins of the idle time on the chat and then in the 16th minute, the session is destroyed.
So, once the user logs off from the web application, the botUsersession is persisted for 15mins more.
In case, if the user logs in within the 15mins, he/she will still have the previous chat session continued.
If you do not want the botUsersession to be carried when the user opens the chatwindow after logging in, then please follow the below step:
1- On the onConnect event in the Default conversation >> event handlers, select the option to run script.
Here, you can add a snippet to set the botUserSession key “undefined”.
Let us know if you need any further clarification.
I am on Bot builder version 6.2.3.
In this version, we do not have on connect event.
Any other way to do so?
Also, how and when this onConnect will be fired?
Bot connection is acceptable but in case if gets fired on reload of chat window then it also won’t help.
You can also achieve this scenario by sending a message to the bot through BotKit when the chat window is closed and then validate in the bot, for message “xyz”(from botKit) set the botUserSession to undefined.
Please integrate BotKit and try to implement. We will be there in case of you face any errors/issues while implementing.
I added one method to chatwindow.js file for clearing user session which I call in case user logs out. This method is calling sendMessage with intent to clear user session.
Does anyone have an example snippet to set the botUserSession key to “undefined” via the onConnect event in the Default Conversation?
Also, does anyone know of a manner in which to have the bot clear the onscreen transcript after 5 minutes of inactivity without having to close the chatbot?