Im wondering if it is possible to add set matched entity properties as context.
I am describing my use case which hopefully clarifies why I am trying to do this:
Imagine I have a entityType called "Animals" with the following properties -> synonyms mappings
{
Cow: ['Mammal','Moo'],
Frog: ['Amphibian','Croak']
Dog: ['Mammal','Bark']
}
I have an Intent("Intent1") which has Animals entityType as a parameter
Use case 1: If Intent1 is called I want to add the matched animal in context. For example if the user says "Bark", I want to add "Dog" in context. I would also like to have a follow up intent to intent1 (call it Intent2) which displays the matched animal from context.How can I make this work
Use case 2: I want to get matched with one and only one animal such that when Intent2 is invoked it only displays one matched animal not many. So for example if Intent1 is invoked with "mammal", I want to add "Cow" and "Dog" in context .Such that when intent1 is invoked again it only tries to create a match from the earlier matched entities. Thus if the user says Croak after having said Mammal then Frog should not get matched.
So the workflow should be:
Intent1 invoked with "Mammal" -> ["Cow","Dog"] put in context
Intent1 invoked with "Croak" -> ["Cow","Dog"] remain in context
Intent2 is invoked -> "Please narrow down to one animal"
Intent1 is invoked with "Dog" -> "Dog" is put in context
Intent2 is invoked -> Your matched animal is "Dog"
PS: I would prefer a solution without a Webhook
When you add a parameter to an intent that has a output context, the parameters are automatically added to the outputContext. As long as the context is available you should be retrieve the parameters in your follow-up intent by using #[ContextName].[ParameterName].
Intent1
Intent 2
Result
Usecase 2
Since you prefer an option without webhook, your options are a bit limited. It's not possible to narrow down on the available entity values based on what the user said. Dialogflow will always attempt to match the user input to all available values of an entity.
If you decided to use a webhook, you would have a second option. You could set "Dog" and "Cow" in the context and if the user gets invoked again, you check the user input against the values in your context. If the user says "Croak" you can return a no match response via code.
Related
A number of my Intents respond to the same words - "yes" and "no".
I'm using the inline editor to handle requests/responses.
Because many of the intents respond to the same words "yes"/"no" I set up one entity called response.
So for Intent1 under the Action and parameters tab there is:
parameter: intent1response, entity: #response, value: $intent1response
For Intent2 there is:
parameter: intent2response, entity: #response, value: $intent2response
So basically i'm just changing the parameter and value for each intent but using the same entity.
But that doesn't seem to work and is messing around with contexts, etc. When I change the entity to be unique for each Intent things seem to work fine.
Just wondering if that's correct. I was also just hoping for clarification re: the input box under Actions and Parameters that says "Enter action name" - when an action name is entered here what happens with this action name in fulfilment? Can I just call it to get the parameter?
The short answer is yes, you can use the same Entity in multiple Intents.
The action you specify is passed along to your fulfillment. It isn't a parameter, but is a field that is included.
I want to access a single entity value for multiple intent's in dialogflow (API.AI). I tried adding same value in another entity but it doesn't work either may be i would have missed some thing.
for example like i have an entity containing value like 20 now this value is being used for extracting some details of the user using an intent lets say A. Now i want the same entity value to update some user data which is being done by intent B.The problem here is on using the entity at B intent the intent of A is being initialising. I want that when B intent is being going through the entity value should work according to that respective intent itself but that's not happening.
is it clear now?
I have one intent named "search.category" which has user queries like "32gb phones" and it has a follow up intent to get_brand question like "do you have any specific brand? ".
This can have two type of answers that user can enter brand name or he can say "I don't know."
Is there any way to pass the whole user query in main intent to followup intents.
How can we pass the original user query(32gb phones) as a parameter across the intents?
In the second picture, you can see that two entities are selected, so is there any way to select the other text from user query ( I want the "show me some under 40000")
To do this, you would create a new Output Context on the first intent. Output contexts created as part of an intent contain the parameters that were set by the user when they were created and are available in subsequent intents (for as long as their lifespan is active). You can access the context's parameters either in the response or in your fulfillment webhook.
If you're trying to use values that aren't set in the parameters, then in the fulfillment of the original intent you can set any value you want as a parameter of an Output Context that you create in your webhook.
I have an intent on Dialogflow where the user can ask something similar to this:
"What is the best price for shoes last month?"
Where translate to the parameters:
"What is the #case #metric for #item #date-period?"
So far so good. This intent outputs a context and works fine.
Now,
How do I create a follow-up context that allows the user to update one or more parameters keeping the remaining intact?
Eg:
"And what is the worse?" (only the case is updated)
"And what is the best for sandals?" (case and item are updated)
"And what is the worse last week?" (case and date-period are updated)
"And how about boots last week?" (item and date-period updated, )
etc.
I mean, I have four parameters, and I would like to provide to the user the ability to continue the conversation (context) changing one or more parameters.
There is any way to create some kind of "smart follow-up intent" or do I need to create all possible combinations follow-up intents?
Thank you in advance.
Start by adding an output context for your original intent, lets say "search". Make this intent calls your fulfillment and save the parameters, something like this:
app.data.case = app.getArgument('case');
app.data.metric = app.getArgument('metric');
app.data.item = app.getArgument('item');
app.data.date-period = app.getArgument('date-period');
Now create another intent and add some user says expressions that covers all parameters and have as input context the same context you put on the original intent. Make this intent also calls your fulfillment and from what parameters are filled you can realize what the user is trying to change so whatever the user has not provided you can get it back from what you had saved before:
let _case = app.data.case;
Say I create an intent AskForFruit in Dialogflow where the user says:
I want an apple
here apple gets assigned to a param fruit
I want to restrict the value of fruit to 'apple', 'orange' and 'banana' only
If the user says 'peach' the agent will respond with 'Please select between apple, orange and banana'
How do I restrict the value of fruit to these 3 fruits only?
There are two things you need:
fruit should be assigned to a Custom Entity type
You will need a Fallback Intent (or a lower priority Intent) to handle input if there isn't a match.
Custom Entity
You'll create a custom entity by selecting the Entity menu item on the right and then Create Entity.
You'll enter in the possible values this Entity can take on. You can also add aliases for some of the entities if you want.
When you go to create your Intent, you want to make sure the entered phrase has a word highlighted and the Entity Type correctly selected for that word. (And, as #Ido notes in the comments, you probably want to say the parameter is required.)
Fallback Intent
That handles the case when the user says one of the valid fruits. But what about invalid fruits? How you handle this depends on what other things you're talking about.
The easiest solution is to create a Fallback Intent, which is an intent of last resort if nothing else matches. If you're using contexts, you can create a fallback intent for a particular context, and this is a great way to keep track of where you are in a conversation.
In either case, you'd edit your responses to tell them what valid fruits they can pick.
If, however, you want to very specifically respond if they ask for something you don't want, you can create a lower priority intent that will match if there isn't a better match. This is useful if you have a lot of conversation parts and aren't using contexts (but you should use contexts) or want to reserve your Fallback Intent for a more general message.
You change the priority of an intent by clicking on the dot next to the intent name.
So, for example, if you have an AskForSomethingElse intent that would match the more general #sys.any type, you could have it respond with the valid types.