9

When I enter the "reset" command, I want the conversation restart again and clear all the previous dialog, May I ask about how to do it? I had stuck for 2 days. Thank in advanced.

Here with my source code.

bot.dialog('/reset', (session) => {
    session.endDialog();

    var msg = new builder.Message(session)
        .addAttachment(welcomecard_1.welcomeCard());

    session.send(msg);
})
.triggerAction({
    matches: /^reset$/i
});

After I enter the "reset" or "/reset" the previous conversation [in red color] will remove from the dialog and this channel is using direct line. enter image description here

Updated: I had try this code , but not work.

bot.use(builder.Middleware.dialogVersion({ version: 1.0, resetCommand: /^reset/i }));
Eng Soon Cheah
  • 257
  • 1
  • 10
  • 42
  • May I know which channel you are connecting with? – Md Farid Uddin Kiron May 14 '19 at 07:35
  • @MdFaridUddinKiron Direct Line – Eng Soon Cheah May 14 '19 at 08:51
  • I had use this method but not working . https://learn.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-state?view=azure-bot-service-3.0#delete-data – Eng Soon Cheah May 16 '19 at 07:41
  • Managing state data has nothing to do with the conversation history in the channel client. That's a visual element rendered in the UI. Clearing the conversation history will be the responsibility of the client application. Did you build the Direct Line client yourself? – Kyle Delaney May 16 '19 at 22:51
  • I did not build the Direct Line myself. – Eng Soon Cheah May 17 '19 at 02:28
  • Your channel will be webchat, right? – Nicolas R May 17 '19 at 08:55
  • @NicolasR is directline and publish in web. – Eng Soon Cheah May 17 '19 at 09:28
  • Directline... so you implemented your own webchat? Or is it using Bot Framework's webchat (https://github.com/Microsoft/BotFramework-WebChat)? – Nicolas R May 17 '19 at 09:31
  • @NicolasR No and using the node js. we still using SDK v3 not yet v4. – Eng Soon Cheah May 17 '19 at 09:34
  • 1
    You are talking about the bot's code side, I'm talking about the channel where you interact with your bot. Here you are asking to clean a conversation on a UI, the main point is... what is this UI? Directline is not a UI, it is the communication (used by the Webchat UI, used by custom UI...). And as Kyle said, "Clearing the conversation history will be the responsibility of the client application" so you must tell us what is this client application – Nicolas R May 17 '19 at 09:38

1 Answers1

1

You can clear the dialog stack using session.clearDialogStack() or session.endConversation() or session.reset(). Here are the differences between them:

session.clearDialogStack()

  • Does nothing extra

session.endConversation()

  • Optionally sends a message to the user
  • Clears conversationData and privateConversationData
  • Sends an endOfConversation event to the channel

session.reset()

  • Begins a new dialog
Kyle Delaney
  • 11,616
  • 6
  • 39
  • 66