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

Unknow String been prompted

Open ernanirst opened this issue 10 years ago • 5 comments

In this example, the bot should only answer "That's correct! The meaning of life is 42" if the user says '42', and it should say "Sorry you couldn't figure it out. Everyone knows that the meaning of life is 42." if the result is something else.

However, if the user tells the bot the answer is "12", the response of the bot is "I didn't understand. What's the meaning of life". Why would the bot say "I didn't understand."? This string isn't in the code, and why he wouldn't print the 'else' message "Sorry you couldn't figure it out. Everyone knows that the meaning of life is 42."?

ernanirst avatar May 28 '16 16:05 ernanirst

So the "I didn't understand." part is coming from the validatedPrompt(). The answer of "12" didn't pass the validation so it triggered the default response. You can tweak this message by passing in a retryPrompt when you call the validatedPrompt().

Stevenic avatar May 28 '16 17:05 Stevenic

Hello @Stevenic, so if my validate function returns false it will trigger the default response? It sounds a bit odd that Bot Framework would give any response at all, in my opinion it should only throw errors and in this specific case, I don't think it shouldn't do anything because I want to treat the response. But this is just a suggestion.

Anyway, would you mind to give me an example on how to pass retryPrompton validatedPrompt()? Because on my understanding, I should only give as parameters the validate function and the promptType (which is text).

ernanirst avatar May 28 '16 19:05 ernanirst

If you want to process the response and generate your own reply, don't use the validatedPrompt(). Just call Prompts.text() and then implement your own logic to validate the users response. The validatedPrompt() is intended to take a fairly boiler plate set of 20 - 30 lines of code and reduce it down to about 3 lines of code. All of the dialog actions are meant to be helpers. You don't have to use them.

Stevenic avatar May 28 '16 22:05 Stevenic

Thanks for clarifying things. Now it makes sense.

ernanirst avatar May 29 '16 01:05 ernanirst

NP... I'm actually planning to replace validatedPrompt() with a new Custom Prompts system. This new system will let you create prompts that behave more like the built-in ones and give you more control over how re-prompts work & such.

Stevenic avatar May 29 '16 19:05 Stevenic