Syed
Syed

Reputation: 358

Bot Framework: Exit PromptDialog without giving an answer

I ask the user a yes/no question using:

PromptDialog.Confirm(context, AfterChoice_OpenServiceRequest, "Do you want to open a service request?");

to which the user can give a yes/no answer. But, what if the user doesn't want to answer to this at all and rather, ask a different question? Until and unless the user replies with a yes/no, it keeps asking them the same question for 'n' number of times.

I could pass n=0 to attempts parameter, but that would still require the user to answer with a yes/no at least once before being able to ask something else.

Could the user not just proceed and ask something else in response? How can I handle this?

Upvotes: 1

Views: 977

Answers (2)

user6269864
user6269864

Reputation:

Until the release of the feature mentioned by Lars, the only option is to create a new class that would inherit from PromptDialog, or implement your conversation logic manually.

Upvotes: 0

Lars
Lars

Reputation: 10573

The pre-release version of the the SDK contains the concept of "triggerActions". You can use these to interrupt any Dialog. In the sample below, the user can interrupt the color prompt, by typing "weather":

enter image description here

Code:

bot.dialog('/', function (session) {
    builder.Prompts.choice(session, "What color?", "Red|White|Blue");
});

bot.dialog("weather", function (session) {
    session.send("It's cold and rainy");
    session.endDialog();
}).triggerAction({ matches: /^weather/i});

To get the pre-release:

npm install -save botbuilder@next

Upvotes: 1

Related Questions