Best way for synonyms if data is stored outside dialogflow? - nlp

I want to create a chatbot. One of the intents is who-is which allows users to ask "Who is" for Arabic names to get information on a person. I have people stored in a database (firestore). I would like the user to say "Who is Saalih Uthaymeen?" But they may ask "Who is Shaykh Saalih al-'Uthaymeen?" as well. The names are different, but they're the same really. And they're close in spelling.
I noticed a synonyms feature in dialogflow, but I don't have the names stored in dialogflow so I don't know if it's useful. Since the synonyms have similar spelling, can't dialogflow help? Otherwise, I see the following options:
Option 1. Manually create every name and its synonyms in dialogflow.
This is manual hard work. Even if I programmatically enter every name, I have to manually enter every synonym. And I have 2 or 3 hundred names.
Option 2. Manually create synonyms in my database.
Basically, I have a table of people... so I would create a new table mapping every person to every synonym possible for his name. Since the spellings will be very similar, I'm confident this is a waste of work and time.
Is there any other option Dialogflow offers?

Related

DialogFlow training phrase

I am building chatbot for universities. In the training phrase, how can I add the generic parameter without specify it. For example, if I need to ask the specific course offered this semester "Is CSCI1000 offered this semester?". And my database had more than 100 courses. So I need to type more than 100 training phrases for each courses with that question. Can I put it in generic form like this "Is course_name offered this semester?". course_name will match with the specific course name that user type in. I know DialogFlow is deprecated template mode. Do we have any other way to make it simpler? Please help.
In DialogFlow (DF) you can do more than that. Based on your provided information, let's assume you have 100 courses ID and names in your database. Here's the steps you should take to make DF recognize them:
Create an entity for your courses name (course_name)
Import course id (CSCI1000) as entity name (you can also import the name of the course as synonym, for situations where the user asks "is Computer Science offered this semester?"). You have to implement all this in your back-end
At this point you have an Entity with name all your courses from your database (so whenever the used types the name of that course DF will recognize it). Note that you can use other tricks for creating entity using regular expressions.
The final step, you have to create one intent 'Open courses' and and add Parameter, and for the entity use your created entity above (#course_name). Then type few training phrases. DF will detect courses id.
This is what came to my mind since I have done something similar before. For your reference Link to DOC

Entity Extraction/Validation in Bot Composer

I have a composer text input task with the following settings. I'm making a bot testing the capabilities of Luis integrations with a bot. The issue I'm facing is not the entity recognition itself; rather the entity validation on the input task for the entity. I only notice this when using a text input task and have the entity validation working for other tasks (specifically datetime).
Current Entity User Input Task
To illustrate my issue, here are two current behaviors of the bot:
WAI: I say something like "I want to make an appointment and my contact number is (800)-234-5678". This not only triggers my intent model and skips the user input question where I ask for the user's phone number (seeing as they provided one already) and the conversation.phoneNumber variable is (800)-234-5678
Not WAI: I say something like "I want to make an appointment and my contact number is abc". This triggers my intent model as desired but skips the user input question where I ask for the user's phone number (because it thinks they provided one already) and the conversation.phoneNumber variable is abc. Ideally, this is where I would think validation would happen and it would ask the question "What is a good phone number for our office..." seeing as abc isn't a phone number.
For reference, this is the documentation I'm following:
https://learn.microsoft.com/en-us/composer/how-to-define-advanced-intents-entities
I considered a regex validator as an option because phone number is such a trivial entity that can be easily defined, but something more complex/diverse (such as geographic location, currency, etc) would be better handled by whatever dictionaries Microsoft has in place for built-in entities. I can see the raw data when I type in an utterance that shows no entity is being picked up (so SOMETHING is working in the background). I'm just curious if I can make use of that functionality in a bot composer task.
As I said before, this is working fine when validating if a user entered a date/time on a separate task; I'm hoping there's a feature for this for other built-in, text-based entities in the bot composer.
I assume that whatever built-in entity recognition that Microsoft has for their built-in entities here https://learn.microsoft.com/en-us/azure/cognitive-services/luis/luis-reference-prebuilt-entities is vastly superior to whatever regex I can come up with, and some type of built-in validation would be handy for more complex bots.

LUIS: Identify "normalized" value based on synonyms automatically

I am currently developing a chatbot that recommends theater plays to the user.
It is working pretty well, but now I want to enable the user to get recommendations based on the type of theater plays (like funny, dramatic, sad).
Nevertheless, as I do not know how exactly the user is phrasing the request also synonyms might be used (funny: witty, humourous, ...)
What is a good solution to get these types from the user's request in a normalized way?
Typically I would use the List entity, but then I have to insert all synonyms for each possible value by myself. Is there a way how i can define my "normalized" values and synonyms are automatically matched by LUIS (and improved by further training of the model)

How to create a search form with dialogflow

I am trying to make a search algorithm with dialogflow that could take any combination of: first name, address, phone number, zip code or city as input to a search algorithm. The user does not need all of them, but we will refine our search with each additional answer until we only have one result. Basically we are trying to identify which customer we are talking to.
How should this type of intent (or set of intents) be structured? We have tried one intent with multiple parameters, but we do not need all of them to be required. We have also written a JavaScript function for fulfillment but how can we communicate back to dialogflow as to whether we need more information?
Thank you very much for your help.
Slot filling is designed for this purpose.
Hope that helps.
Please post more code/details to help answers be more specific.
First, keep in mind that Intents reflect what the user is saying, and not typically what you're replying with or what other information you need. Slot filling sometimes bends this rule, but only if you have required slots.
Since you don't - you need a different approach.
This can be done with a single intent, although you may find that multiple intents make it easier in some ways. The approach is broadly the same:
When you ask the question, make sure you set an Outgoing Context with a relatively short lifespan (2-3 is good) to indicate you are collecting user info.
Create an Intent (or Intents) that have sample phrases that capture the information you need.
Some of these will have obvious entity types (phone number and zip code) while others will be more difficult (First name has a system entity type, but it doesn't include all possible first names).
You will need to create sample phrases that collect the parameters by themselves, along with phrases that make sense. You're the best judge of this, and you should probably write some sample conversations before you write the phrases.
In your fulfillment, you'll figure out if you have enough information.
If you do, you can reply and clear the Context that was set. (Clearing it is important so Dialogflow doesn't match the information collecting Intent again.)
If you do not, you can add the information you have as parameters to the Context so you can save it for later processing, make sure you reset the Context lifespan (so it doesn't expire), and prompt the user for additional information. Again, having a conversation mocked out ahead of time will help here.

Dialogflow: Not able to identify simple phrases

Not able to identify simple phrases like "my name is not Harry, it's Sam".
It is giving me name as harry and company name as Sam, Since name and company name was required in the same sentence.
It should have taken name as Sam and prompted the user again for company name OR should have given complete fallback.
Hi and welcome to Stackoverflow.
Dude. This is not a simple phrase.
Negative questions are always very difficult to catch by Dialogflow.
Suppose I have a question like,
I want to check *google* revenue for the year *2017*
As you can see, google and 2017 are the entities.
But now in the same way if you say,
I don't want to check *google* revenue for the year *2017*
The chances of hitting that old intent is very high as dialogflow matches almost 90% of this sentence with your old sentence. So it might fail.
Hope you are trying to ask something similar to this.
Anyhow coming to your point, If company name and name are different entities, then
Two things you can avoid:
As everyone mentioned,check your entities. The values should not be present in both the entities. This will fail because dialogflow will not know whether it should treat 'Sam' as your name or company name.
If you are not using the values from an entity, instead using '$ANY', then It has a very high chance of failing. And If you are using Dialogflow's system entity like, $given-name, then that is also not preferred as it does not catch all the names. So avoid these entities.
Things you can try:
Train Train And Train. As you would be aware, the training section in dialogflow is pretty good. Train it a few times and it will automatically learn and master it.
But , please note: Wrong training will result in wrong results. It should be 100% accurate. Always check before you approve a training.
And try using webHooks, actions, and/or events to figuring your way out from an external API.

Resources