Clear session.userData
I'm testing my bot after deploying to FB/Skype. I'm wondering if there is a way I can clear all session data and test from scratch? I am unable to tests part of my logic since userData is persisted across the conversation.
Follow up: As of now I have a command that my bot recognizes and I can clear the data using that. But I don't want to expose this to users. I would like to do it myself behind the scenes.
@suvamsh If you are using nodejs, you could add this middleware:
bot.use(botbuilder.Middleware.dialogVersion({
version: 1.0,
message: 'Conversation restarted by a main update',
resetCommand: /^reset/i
}));
That manages the versioning of a bot dialogs. If I'm not wrong (I'm not 100% sure about it) you can increase the version every time you want to clean all session data. Your bot would also understand "reset" as a command that cleans everything as well.
Please let us know whether it works or not if you try it.
@palmerabollo that won't delete userData... @suvamsh can I ask what are you saving in userData that you want to delete? Just wondering if what your storring should really be persisted using userData...
If you want to delete userData for all of your users you'll need to create a piece of middleware similar to dialogVersion() that lets you version userData.
Closing as it appears the question was answered. Please feel free to open a new issue if you'd like to discuss further. Thanks!
thats what i did bot.dialog('/delete', (session) => { delete session.userData session.endDialog('Everything has been wiped out')
}) .triggerAction({ matches: /delete all/i, confirmPrompt: "This will wipe everything out. Are you sure?" });
@palmerabollo Your method worked for me. Big thanks
@slidenerd It's wrong, read the documentation. https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-state#delete-data right way is
bot.dialog('/delete', (session) => {
session.userData = {};
//session.privateConversationData = {};
//session.conversationData = {};
//session.dialogData = {};
session.endDialog('Everything has been wiped out')
})
.triggerAction({
matches: /delete all/i,
confirmPrompt: "This will wipe everything out. Are you sure?"
});