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

How can you interrupt a dialog flow in progress?

Open oztheozoz opened this issue 10 years ago • 4 comments

Let's say I have the following code:

const intentDialog = new builder.IntentDialog({ recognizers: [recognizer] });
bot.dialog('/', intentDialog);

intentDialog.matches('how_are_you', function(session) {
  session.send("Doing very well! Thanks for asking :)");
  session.beginDialog("/i_can_help_you_with");
}, function(session) {
  session.endDialog();
});

intentDialog.matches("intent_a", [function(session) {
    builder.Prompts.choice(session, "Please choose from:", "Option A | Option B", { listStyle: listStyle['button'] });
  },
  function(session, results) {
    if (results.response.entity === "Option A") {
      session.beginDialog("/Option_A");
    } else {
      session.beginDialog("/Option_B");
    }
  },
  function(session) {
    session.endDialog();
  }
]);

This is what I want to do: If I am at builder.Prompts.choice of intent dialog "intent_a" and the user types "how are you", I would like for the "how_are_you" intent to start. Then when it is finished, resume the flow from intent dialog "intent_a".

This is what I see it do: If I am at builder.Prompts.choice of intent dialog "intent_a" and the user types "how are you", I get the default message from failing to select a valid choice.

Can anyone please point me in the right direction of how to solve this problem? Thanks in advance.

oztheozoz avatar Aug 08 '16 18:08 oztheozoz

Any update on this?

oztheozoz avatar Aug 27 '16 02:08 oztheozoz

@willportnoy @muzahmed any update?

oztheozoz avatar Sep 15 '16 04:09 oztheozoz

@oztheozoz sorry for the delay... We're actually working on a solution to this. For now you would have to actually write a piece of middleware to intercept things which is not going to be as clean as you'd like. We're working on a solution that will let you accomplish the above using actions. You can almost do it today with actions but you're limited to using RegEx's. A future update of the SDK will add support for using Actions with LUIS models which should address this need.

Stevenic avatar Oct 03 '16 22:10 Stevenic

Great to hear that this is being worked on. Thanks for the update and suggestions for work arounds!

oztheozoz avatar Oct 03 '16 22:10 oztheozoz