I am using Microsoft Bot Framework to develop chatbot and my questions is that how can I handle incorrect responses from a user.
Suppose bot asks for name of user and he or she replies "don't know".
I have seen in boiler plate code of bot framework that it handles minimum length validation, but how can I handle this logical checking.
Thanks in advance.
I am assuming you are using the v4 C# SDK, let me know if this is not correct and I can update my answer for node or v3 for you.
This Sample Does exactly what you are trying to do It has a validator that checks the length of the user's input and reprompts if the length is too short. You can see this in this method
In general name validation is fairly difficult because names can be very diverse and contain special characters like "-", "'", and others. Using a prompt with a custom validator should give you the opportunity to at least add some validation like length and numerical character checking.
An expected answer normally has a known format. If bot is asking a name then the name would not have numbers and special characters.. You can do a quick check if the words returned by user are part of standard english words (there are plenty libraries having this list of words). You can even pass the returned sentence to LUIS and see if you get a known intent, and then you can disqualify the answer.
Related
We need to extract a number from a phrase. For example:
"hey, 1234" -> "1234"
"ok, 4567" -> "4567"
"b3456f" -> "3456"
But we don't found how to iterate through a string using only language generator of the Bot Composer.
We try things like:
join(foreach(createArray("ab c"), x, concat(x, '-')), '')
But with no result... is there any prebuild function that converts a simple string on an array of chars, so we can iterate char by char using foreach?
Thanks!
As far as I know, this currently isn't possible as there's no way to iterate over a string or split a string into a new array by character. I've opened a GitHub issue to request it as an enhancement.
For:
"hey, 1234" -> "1234"
"ok, 4567" -> "4567"
You can use split().
Unfortunately, you're out of luck for your "b3456f" -> "3456" example, unless you know it's going to come in that exact format, in which case, you could use substring().
You could maybe look into using a Regex to do this, if you know the formats will be pretty controlled, but another option is to look at the LUIS language understanding services from Microsoft, which are built exactly for understanding different parts of a text message, especially in a bot context. Here's a link to getting started with this, for C# (on the menu just below in this link, is a Node example if that's what you need).
There's also a tag here on Stack Overflow focused just on LUIS, if you run into trouble or need any more help.
Hope that helps
[Update] I re-read your question and I see now it's about BotComposer, not a custom developed bot. As a result, the sample I linked to is not valid, but LUIS certainly is. I haven't used Bot Composer myself, but LUIS is integrated as part of it - see here.
I have an intent named: "Smalltalk.greetings.how_are_you"
When I run a Luis query, the json responses gives "Smalltalk_greetings_how_are_you"
Why so ?
If this intended please refer to the documentation explaining why and to use special characters as intent name because I really need to do so.
The closest thing to documentation on this is found here. However, it doesn't specifically mention periods.
I'll file a bug report/feature request to add some documentation on this.
My guess is that LUIS replaces all separator characters with underscores for consistency. There may be some trouble parsing some due to the various ways the JSON gets serialized and deserialized.
That being said, as you're now aware of the behavior, I'd either account for it in your code or change your intent names in LUIS. If you're worried about this happening with other intent names, you could use RegEx matching in your code when you look for intents.
I know, not ideal, but the only part of this that's likely to change is updated documentation, which I'll put a request in for.
What is the best practice approach to handle typos / misspelling on LUIS List Entities?
I have intents on LUIS which use a list entity (specifically Company Department - HR, Finance, etc). It is common for users to misspell this when putting forward their utterance. LUIS expects an exact match, it doesn't do a "smart" match, and therefore doesn't pick up the misspelled entity.
a) Using bing spell check is not necessarily a good solution. e.g. Certain departments are acronyms such as VRPA - and bing wont correct a typo there.
b) When I used LUIS a year ago, I would pre-process the utterance and use a Levenshtein distance algorithm to fix typos on list entities before feeding them to LUIS.
I would imagine that by now LUIS has some better out of the box way of handling this very common use case.
I'd appreciate input on what the best practice approach is to handle this.
#acambitsis and I exchanged messages via his UserVoice ticket, but I'm going to post the answer here for others.
A combination of Bing and Simple Entities might be what you're looking for, then (they're machine-learned).
I was able to accomplish something close and attached images.
In entities, I created a Simple entity with the role, VRPA. In intents, I created the Show Me intent and added sample utterances "Show me the VRPA" and "Show me the VPRA". I clicked on V**A and selected the Simple Entity:VRPA role. After training, I tried "show me the varp" and it correctly guessed "varp" was the "Simple:VRPA" entity.
You may also find RegEx entities useful. For acronyms, you could do something like: /[vrpa]/i and then any combination of VRPA/VPRA/VARP/ARVP would match.
I highly recommend reading through the Entity Types and Improve App Performance to see if anything jumps out to solve your particular issues.
This may not do exactly what you're looking for. If not, I'd recommend implementing a fuzzy-matching algo of your choice.
entities
intents
I trained my luis model to recognize an intent called "getDefinition" with example utterances such as: "What does BLANK mean" or "Can you explain BLANK to me?". It recognizes the intent correctly. I also added an entity called "topic" and trained it to recognize what topic the user is asking about. The problem is that luis only recognizes the exact topic the user is asking about if I used that specific term in one of the utterances before.
Does this mean I have to train it with all the possible terms a user can ask about or is there some way to have it recognize it anyway?
For example when I ask "What does blockchain mean" it correctly identifies the entity (topic) as blockchain because the word blockchain is in the utterance. But if I ask the same version of the question about another topic such as "what does mining mean", it doesn't recognize that as the entity.
Using a list or phrase list doesn't seem to be solving the problem. I want to eventually have thousands of topics the bot responds to, entering each topic in a list is tedious and inconvenient. Is there a way LUIS can recognize that its a topic just from the context?
What is the best way to go about this?
Same Doubt, Bit Modified. Sorry for Reposting this here.
At the moment LUIS cannot extract an entity just based on the the intent. Phrase lists will help LUIS extract tokens that don't have explicit training data. For example training LUIS with the utterance "What does blockchain mean?" does not mean that it will extract "mining" from "What does mining mean?" unless "mining" was either included in a phrase list, or a list entity. In addition to what Nicolas R said about tagging different values, another thing to consider is that using words not commonly found (or found at all) in the corpuses that LUIS uses for each culture will likely result in LUIS not extracting the words without assistance (either via Phrase list or list entity).
For example, if you created a LUIS application that dealt with units of measurement, while you might not be required to train it with units such as inch, meter, kilometer or ounce; you would probably have to train it with words like milliradian, parsec, and even other cultural spellings like kilometre. Otherwise these words would most likely not be extracted by LUIS. If a user provided the tokens "Planck unit", LUIS might provide a faulty extraction where it returns "unit" as the measurement entity instead of "Planck unit".
I'm an absolute knob when it comes to programming, so I ask of your help.
Essentially I'm trying to use the api.ai interface to create a character counter (in slack) where when a user says something like "hi" the bot will respond with "2".
So far I understand that I'm supposed to use an entity in order to achieve this transformation, and I have tried mapping reference words like "hi" with the synonym "2". However, the entity transformation ends up having the bot spew out exactly what the user initially said (ex. "hi"), instead of my desired outcome ("2").
Am I going about this wrong, or am I supposed to use an already existing entity to in my new entity? I apologize in advance as I literally picked this thing up yesterday, so I don't know much about it.
Any help is appreciated!
You cannot write logic in api.ai, meaning you cannot write a function that takes as input a message and returns the number of characters.
What you would need, I believe, is to integrate the api.ai with an external web service where you can write your business logic.
Have a look at Slack + Webhook Integration Example https://docs.api.ai/docs/slack-webhook-integration-guideline
However, if you just want to count the number of chars in a message, I do not see the need for api.ai.