Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear the existing dialog

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 }));
like image 783
Eng Soon Cheah Avatar asked May 14 '19 01:05

Eng Soon Cheah


1 Answers

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
like image 50
Kyle Delaney Avatar answered Nov 05 '22 21:11

Kyle Delaney