Dialogflow values are stored in wrong parameters

2019-08-04 11:06发布

问题:

I have a dialogflow intent which includes different parameters. Although parameter names are unique, in some cases values are stored in wrong parameters and not in their own parameter.

1.png

2.png

3.png

4.png

Image 1.png shows my intent and its "User Says" sentences.As you can see in 2.png, I have a VarName user defined entity for each variable name.Now in 3.png I try dialogflow by writing "Change Loan Term to 20". But as you can see in 4.png instead of putting 20 in "loan-term" parameter, dialogflow puts "Loan Term" value in "years-to-average-principal" which is wrong parameter for this sentence.

I hope I could make it clear. Thanks in advance,

回答1:

The problem is that you have two sample phrases that, from Dialogflow's perspective, match the exact same kind of inputs. By assigning a portion of a phrase to a parameter, you're basically saying that this part of the phrase can be replaced by anything that matches the parameter's Entity type.

So the phrase "Change Years to Average Principal to 5" can be thought to match something like Change @VarName to @sys.number. But the phrase "Change Loan Term to 30" also matches that.

You have several solutions, depending on how you are doing fulfillment and processing these numbers.

Solution 1: Use different Intents

Instead of making one Intent that lets you change all the possible variables, create multiple Intents that capture phrases the way people would express them and tie your backend to handle each intent specifically. So you might have one Intent that looks like this

and another Intent that looks like this

In your fulfillment, you'd check which Action was triggered to determine which value to adjust and then check the parameter to see how to adjust it - if a number was set, you'd use that number, otherwise you might adjust it by the percentage. You could add other values for other phrases if you wanted to do relative adjustments.

Solution 2: Use generic value parameters

Similar to solution 1, instead of naming each value parameter after the attribute you want to adjust, you'll just have a few generic ones (percent value, number, etc) plus the parameter to determine the attribute (your VarName parameter and Entity type).

The Intent is easier to specify, but on the back end, you'll need to determine if the user has specified an value parameter that doesn't make sense for the attribute (such as the user specifying a percentage for changing the Term) and generate an error. It might look something like this:

Solution 3: Combine the two

You can use whatever parameter names you want, of course. By default, it names the parameters after the type, because that's nice and generic. So you'd use the Action to figure out what to set, and then the generic names to figure out how to set or adjust it.

Those might look something like this:



标签: dialogflow