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.
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.
I can show you how I do this in node.js. You can probably port it to C#:
http://www.pveller.com/smarter-conversations-part-3-breadcrumbs/#Relaxed-Prompt
The idea is to make sure that Bot Framework doesn't re-prompt if the answer is not one of the options (buttons) provided.
Related
Is it possible for c# to look past typos in user input and execute the proceeding code given that the user input is very similar to the condition. Lets say for example, we ask the user to pick an option from a switch consisting of colours."blue" is the desired colour and this has some code following it but the user inputs "bluu" or "glue", would c# be able to pick the "blue" option given that it can recognise the input is closer to blue then other colours such as "red". Is there some sort of method we could apply to this.
You could look into using the Levenshtein Distance Algorithm to check how similar the strings are, maybe if the algorithm finds the strings are only one character in difference you could then execute whatever code. It would probably be easier to use some conditional statements as opposed to a switch in this case.
see this answer for an imlementation of this algorithm
Very similar question to this one: How to get PromptDialog.Choice features and still allow other User responses in Bot Framework?
I want to extend the PromptChoice to give a user a number of options, something like this:
Here's what I found:
Option 1
Option 2
Option 3
Which do you want information on?
If the user responds with "Option 1", I'd like to use the PromptChoice to pick it. But if the user responds with more natural language, something like "Where is Option 1"? even though the out of the box PromptChoice does not handle this question, I'd like to respond given information I have on Option 1.
I understand that I have to override the TryParse, but what I'm confused about is how to parse the message myself, and then pick the right option out of the list of options. What do I have to override in PromptChoice to add this functionality?
First have a look to the PromptChoice implementation and its TryParse method, here
You will see that it is made in 3 recognition steps:
Recognize choices (trying to recognize the possible choices you provided)
Recognize numbers ("number 1", "choice 3", etc)
Recognize ordinals (like "first value", "last choice", etc)
Those steps will provide a topScore and topEntity, and the best of these 3 values is returned (if the topScore is superior to a minScore value).
Note that each recognition can be disable in PromptChoice setup, and the minScore value can also be setup there.
How to edit the behaviour?
One idea would be to set a minScore value quite high, and to add an else statement to do your dedicated code inside.
That would be:
if (topScore >= this.minScore && topScore > 0)
{
result = topEntity;
return true;
}
else
{
// Your custom code here
// You have access to your list of options, to your message...
}
I cannot add more details about what to do in your custom code here as your question is not clear enough about that. If it is "known fixed questions" it will be a lot easier than understand all natural language possibilites.
Im searching about services/strategies to detect when entered names in forms are spammy, example: asdasdasd, ksfhaiodsfh, wpoeiruopwieru, zcpoiqwqwea. crazy keyboard inputs.
I am trying akismet is not specially for names (http://kemayo.wordpress.com/2005/12/02/akismet-py/).
thanks in advance.
One strategy is having a black list with weird names and/or a white list with normal names, to reject/accept names. But it can be difficult to found it.
you could look for unusual character combinations like many consecutive vowels/consonants, and watch your registrations and create a list of recurring patterns (like asd) in false names
i would refrain from automatically block those inputs and rather mark them for examination
Ask for a real email and send info to connect there. Then get info from the account.
No way is really safe anyway.
If speed isn't an issue, download a list of the top 100k most common names, throw them in an O(1) lookup data structure, see if the input is there, and if not, you could always compare the input to the entries using a string similarity algorithm.
Although if you do, you will probably want to bucket by starting letter to prevent having to perform that calculation on the entire list.
All-
I've been trying to search and find a solution for a while but I'm still stumped on 2 questions
1) Basically lets say I have this key:
System.Windows.Forms.Keys.A
And I want to send it using SendMessageto a window where the keyboard layout could be ANYTHING. It could be US-EN, or DE, or BE, anything.
How can I achieve this? Right now the windows are interpretting the key differently based on their regional settings.
I thought maybe KeysConverter but I don't see a function that would help with this.
2) Lets say I just have a list of keys, how can I convert them to the correct codes (virtual?) to pass to SendMessage?
Thanks in advance!
I would like to clear the search box in metro search charm after the user accepted one of the result suggestion my app is providing to the charm. How? Sounds easy but it is not, SearchPane.QueryText is read only.
I am actually surprised by the default system behavior. After the user accepted the ResultSuggestion (please remember to distinguish from QuerySuggestion) it does not make sense in my eyes to pre-populate the search box with this accepted result...
Try
var searchPane = Windows.ApplicationModel.Search.SearchPane.getForCurrentView();
searchPane.trySetQueryText("myQueryText");
The user's text stays there in case after looking at one of the results they decide "oh that's not it, I will look at this other result from" and the other result could even be from a different app. There is no way for an app to override this.