How can I access alphanumeric values in Dialog Flow? - dialogflow-es

I have a requirement where the user says “ location is ECC86623”, where ECC86 623 is the room number in a building. Is it possible that I can provide an alphanumeric string for intents? Also, I want to take value L1005 also. Or tell me about any method of setting custom values which take every value in the same format like flight number. Is there any way to set the condition like validation or something.

I think what you're meaning to ask about is training phrases as well as extracting and validating the entities from those training phrases (such as location in this case). You can see Dialogflow's Regex sample to get a better idea of how this will look in your fulfillment logic.

Related

Dialogflow parameter and entities

I wanted to know if it possible for dialog flow to store value of parameter without set the entities for it. For example The bot ask the user What is your name? and the user respond with Jack. So dialogflow will store value “John” in the parameter. Thank you.
Dialogflow Web UI
So when working with the Dialogflow Web UI your options are a bit more limited compared to fulfillment and you won't really get around using entities. In the Web UI the best way to extract values from the user input is by using entities and parameters. The only way of using "raw" input via the Web UI is by using the #sys.any entity, but you should be careful with this.
The #sys.any entity takes the complete input from the user and gives it to you, but it doesn't provide any information on what entity the input might be off. For instance, if you ask the user "What is you name?" the user might respond with "John", but they also could respond by saying "Oh.. uhh. My name is John" and if you use #sys.any you get the whole string and you have to detect what is a name and extract it from the input yourself. Entities and parameters do this for you.
You can use the input from the user in your response by using $parameterName in your response
Dialogflow Fulfillment
When working with code the issues with raw input remain the same, you will get the whole user input, but have to do recognition or regexing to retrieve the values yourself.
One benefit of working with fulfillment is that you always have access to the raw input, you can call agent.query to retrieve the raw input, so you are not required to use a #sys.any entity in your parameter setup.
Conclusion
So as I mentioned in the above, there are a couple ways of retrieving the raw input of the user, but in both cases you lose the automatic detection provided by entities and parameters when you do so. While at first it might seem a hassle to work with entities and parameters, if you are going to use the user input for anything, like saving the name or making a decision, I really recommend sticking to the entity approach because it automatically detect the input from the string, you don't have to worry about how the user answers your question, which is a big part of developing a bot.
There are very few cases where using raw input has made developing easier for me in the long run.

Can I extract a parameter based on a terms position in a question?

I would like to perform an action based on a user specific number extracted from a text request: "Open contract number XYZ". Where 'XYZ' is the parameter value I need. There are no obvious boundaries for the content of XYZ. It could be a true number or it could be a string. Can an entity type be based on the term position within the request? I expect dialogflow can match the intent based on the first part of the phrase: "Open contract number". How can I get the parameter value that follows that phrase?
In theory, yes. For this particular use case, you can use the #sys.any system entity. Just make sure to add many training phrases that can help your agent to detect it.
For example:
Make sure to mark the contract numer (or id) in the training phrases, so it can be correctly detected as a parameter.
Now, you can use the value detected in your responses
Example of a detected intent
Keep in mind, that the use of any is not ideal (can lead to unintended behavior); however, if you add a good amount of training phrases and you use contexts to handle the conversation flow, it should work fine.
An additional suggestion. If there's any recognizable pattern in the contract id, you can use regexp entities instead of #sys.any, which will also increase the accuracy.

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.

What is the best method to extract relevant info from Email?

My friend has a small business where customers order services using email. He receives several emails a day and sorting thru it is becoming cumbersome.
There are about 10 different kind of tasks the customer can request, and for each there are one or two words that specify it. The other info present in the emails is the place where the service is to be delivered, the time, and the involved people's names. The email also contains an ID, a long number with a fairly standard format.
The emails are very unstructured, but all contain the key info above. My question is: what is the best method to sweep thru these emails and extract the key info (such as type of service, place, people's names, the ID etc)?
I thought about some kind of pre-processing, then pass it thru AlchemyAPI and then test the Alchemy output using Neural Networks for each feature (key info). This can be supervised learning as I can do a feedback loop all the time, as once the info is inputted, I can have someone to validate.
Any ideas? Thanks
I guess some parts (ID, task, time) can be captured by a regular expression and dictionary matching. Have a look at GATE's JAPE tool.
It should be fairly easy to assemble a dictionary and then use the lookups for the "task", also you can reuse the available jape rules for date/time and write a new one for the ID (also, a simple regex could be fine).
For matching the location and people's names you should be careful, openCalais and alchemyAPI can give you good results if names and places are used in well defined sentences and will probably make more mistakes with some tabular or weird format. Also you can never be sure you captured the place and person correctly so don't rely on that for processing orders directly.
If you have more information about mails' structure or expected names and places (i.e. you have a "clients" table with all possible names), you would probably want to do your own tagging, otherwise I'd stick to openCalais or alchemyAPI + some regular expressions.
P.S. I assume all mails are in English.

Resources