How to match question like current or latest - dialogflow-es

I am trying to model a billing question where the user may ask "What is my current bill?", "What is my latest bill?", "What is my previous bill?" or "What is my bill?".
In the first 2 cases, current, latest identify the most recent bill. Third case (previous) identifies a previous bill. Last does not provide a time identifier so I would like to either match it to latest or do some slot filling.
How do I recognize current, latest or previous as identifiers of ordinality? of bills? What entity type should I use - system or developer?

These sound like they would be good for a Developer Entity where you can have an Entity type of "current" matching things like "current", "latest", "most recent", and "this month" and "previous" matching things like "previous" and "last month".
If you want to, you can also add training phrases such as "What was my bill in February" or "What was my bill two months ago". These might be done as additional training phrases, and possibly even with additional parameters. Your fulfillment can take action based on which parameters are filled in and what those values are.
Remember - Intents capture what the user says, not how you handle what they say.

Related

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.

Bixby natural language input - dollar amounts

I'm trying to allow users to say a dollar amount as input to a Bixby capsule.
So I made a concept of type money.Currency:
structure (Amt) {
role-of (money.Currency)
description (Amount to spend)
}
And then I gave some training examples using it:
[g:SomeGoal] I want to pay {[g:Amt] ($)[v:viv.money.PrefixSymbol:$](25.32)[v:viv.money.CurrencyValue]}
This works fine when the user enters their dollar amount in text, but it frequently fails if the user tries to speak the amount aloud to Bixby.
Example 1 (fails): The user says "I want to pay twenty-five dollars thirty-two cents." Bixby parses this as "I want to pay $25 32 cents" and populates the Amt field with just $25, leaving out the cents.
Example 2 (fails): The user says "I want to pay twenty-five thirty two." Bixby parses this as "I want to pay 2532" and populates the Amt field with $2532, again failing to fill in a value for the cents.
Example 3 (succeeds): The user says "I want to pay twenty-five point three two dollars." Bixby correctly parses this as "I want to pay $25.32" and fills in the Amt field with $25.32. This sounds very unnatural for English speakers though, and I do not think it will be easy to train users to speak this way.
Example 4 (sometimes succeeds): The user says "I want to pay twenty-five dollars and thirty-two cents." Bixby sometimes parses this correctly, other times as "I want to pay $25 in 32 cents" or other similar corruptions.
Anybody have suggestions for getting Bixby to consistently understand dollar amounts in natural language? I am okay with example 2 failing since it is ambiguous, but mainly I would like examples 1 and 4 to succeed consistently. I do have one idea for a workaround (a separate cents field that's manually added to the dollars field by an action), but I'd prefer to avoid that if possible since this seems like a common case that Bixby should be able to handle on its own.
Thank you for bringing this to our attention. I tried the following sentence "Pay one hundred dollars and 25 cents" multiple times and Bixby was able to transcribe it accurately every time.
But your use case (especially #1) is valid as some users tend to not use "and" to tie dollars and cents together. We will raise this internally with our team but I would suggest that you open a ticket with Bixby Developer Support so we can tie your ticket with the issue and keep you posted when its fixed.
Also, your workaround of using a second property to capture cents should work fine too. Let us know if you run into any issues.

entities vs follow-up intent

Suppose i want to make a pizza ordering DialogFlow agent. To order a pizza we need 3 things: size, type and toppings.
If we want to go with follow-up intents approach rather than using entities then there will be so many combinations in which user might provide the information.
1: i want a pizza -> no info
2: i want small pizza -> size
3: i want small cheese pizza -> size and type
4: i want small cheese pizza with olives -> size, type and toppings
5: i want small pizza with olives -> size and toppings
...
and so on
How to solve this problem?
There will be so many combinations if we have more entities (2^n combinations)
Note 1: cannot take entities and slotfilling option as there are so many problems if we go down that road, like re-prompts loop, validation etc.
Is there any better solution?
Note 2: If we use entities, mark them required, and set prompts then many times if it does not get desired input from user it get stuck in re-prompt loop, i.e it keeps asking user same (or random) prompt for same entity. In my use case, it is bad for user experience. If we use follow-up intents instead, then we can set fallback intents for all those intents which solved this problem. (please note that this is just example of the use case)
This is another example of why I used follow-up intents, it solved my date capturing problem as well. I took #sys.date.recent and set a fallback intent to capture inputs like last week, last month etc, this was not possible using slots.
First, remember that Intents should reflect what the user says, not necessarily what you are doing.
On the surface, it isn't clear why slot filling (either with fulfillment or using built-in prompts) won't meet your needs. Since you've indicated that all three bits of information are necessary (size, type, and toppings), you can mark them as such in your phrases and Dialogflow will prompt for the missing information until it gets everything.
You almost certainly do not want to use Followup Intents. These are good when you always have a specific response that you send that will always have a very narrow set of replies from the user, but are very poor if the response from your action will prompt the user to reply in many different ways.
Instead, I would use a related concept: Contexts. (At least if you're not going to use slot filling.) When you ask the question of what they want, set a Context so you know they are. Then have one or more Intents that have this as an Input Context that accept the various things the user might say. Your webhook should see if you have the information you need and, if not, prompt them what else you're looking for. At the end, prompt for a confirmation, but they may say something that adjusts the order.

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.

Extracting relationship from NER parse

I'm working on a problem that at the very least seems to require named entity recognition, but I'm not sure how to go farther than the NER parse. What I'm trying to do is parse information (likely from tweets) regarding scheduling of events. So, for example, I'd like to be able to automatically resolve the yes/no answer to the question of "Are The Beatles playing tomorrow?" from short messages like:
"The Beatles cancelled their show tomorrow" or
"The Beatles' show is still on tomorrow"
I know NER will get me close as it will identify the band of interest and the time (if it's indicated), but there are many ways to express the concepts I'm interested in, for example:
"The Beatles are on for tomorrow" or
"The Beatles won't be playing tomorrow."
How can I go from an NER parsed representation to extracting the information of interest? Any suggestions would be much appreciated.
I guess you should search by event detection (optionally - in Twitter); maybe, also by question answering systems, if your example with yes/no questions wasn't just an illustration: if you know user needs in advance, this information may increase the quality of the system.
For start, there are some papers about event detection in Twitter: here and here.
As a baseline, you can create a list with positive verbs for your domain (to be, to schedule) and negative verbs (to cancel, to delay) - just start from manual list and expand it by synonyms from some dictionary, e.g. WordNet. Also check for negations - again, by presence of pre-specified words ('not' in different forms) in a tweet. Then, if there is a negation, you just invert the meaning.
Since you work with Twitter and most likely there would be just one event mentioned in a tweet, it can work pretty well.

Resources