How to handle dynamic entities in rasa? - bots

Basically i want to capture dynamic entities from my phrases.
Ex: Show me all records discovered in store Google Drive
datasource is dynamic any value can be captured.
I want that it can capture any datasource name.

With an intent like
- I want to show [john](name)'s balance
A message like I want to show paul's balance would get paul recognized as name entity. If "paul" does not occur in any training data, then the obtained confidence score can be low. Nevertheless in your custom action, check the recognized entity if it's in your dynamic list and do the necessary.
If you want the contents of your dynamic list to be recognized and give a high confidence score, then that list will have to be trained whenever it's changed. Python is dynamic but you still need to (re)run the training step.
Hope it helps!

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

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.

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.

How can I access alphanumeric values in Dialog Flow?

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.

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