Ravit D
Ravit D

Reputation: 907

How to create buttons and alow specifying any string

Is there a way to show a question, with buttons, and allow the user to wither pick one of the buttons or specify a different answer?

For instance, have the bot ask: "how can I help you today?" the specify buttons with: "Get on a diet, find a good hotel, learn English" and then let the user either pick one of these, or just way something different such as: "I would like to get to the moon".

We are currently using:

PromptDialog.Choice(context, OnMenuOptionSelected, m_requestTypes, "Here's what I can do for you", descriptions: m_requestTypes.Select(t => t.GetDescription()));

In case the user types in text that does not match the buttons it would show the question again.

Upvotes: 1

Views: 62

Answers (2)

Ezequiel Jadib
Ezequiel Jadib

Reputation: 14787

Definitely doable but not with the out-of-the-box PromptChoice. What you would have to do is to inherit from it, override the TryParse and add your custom logic, to either pass-through any response you receive or just the ones you want.

The CancelablePromptChoice from the ContosoFlowers sample shows this approach, in this case, to accept terms to quit from the PromptChoice.

Upvotes: 2

Pavel Veller
Pavel Veller

Reputation: 6115

I can show you how I do this in node.js. You can probably port it to C#:

The idea is to make sure that Bot Framework doesn't re-prompt if the answer is not one of the options (buttons) provided.

Upvotes: 0

Related Questions