I'm new to Dialogflow and trying to figure out about Context and different Intent.
Basically my need would be to be able to trigger the same Intent with or without a context. But it's seem that it's with or without but not in between.
Here is what I'd like to be able to do:
Imagine a user that ask about Events in a specific Region, then we could give him a response saying : "Don't miss the XYZ Festival in Quebec this Weekend!".
Then, just after, the user asks about the Weather : "How will be the weather this Weekend?"
I'd like to be able to give him the answer for Quebec, because the Event is there and as human we would understand that the second question is about the first.
This is possible with context set as Output Context in EventIntent and Input Context in the WeatherIntent. But inverse could happen.
User can ask about the Weather in a specific region and then ask for Events there. If I set the Input Context in Weather, then it will never be triggered without that context. And if I don't set the Context, then it will ask for the region again.
How do I manage this?
You're on the right track using Contexts, but you're missing how Input Contexts are used.
Setting an Input Context on an Intent means that Intent can be triggered only when that Context is valid. If no Input Context is listed, however, then it will be valid at any time - and you can still use the Context as long as it is valid (ie - as long as it hasn't timed out).
So you can set the location parameter by setting an Output Context (either in the Intent description or, better, in your webhook). Then have phrases for your "EventIntent" and "WeatherIntent" that both take the (optional) location parameter and not. In your fulfillment you might use logic such as this:
If the location parameter comes from the phrase, then return answers based on it and save it in the Context for future use.
Otherwise, try to get the location from the Context and return answers based on that.
If you can't get a location at all - ask for it, and then return answers based on that reply.
Related
I am using contexts within Dialogflow to call the next intent for the user. What I would like to do is have the ability for someone to change their mind on an answer they just entered. For example, as seen in the image below, if I enter a name then it would ask for an email. However, the user should be able to say "can I change my name" and go back to the context where Dialogflow is asking for a name.
I already have that intent implemented but I am trying to figure out how to go back to the question they were going to answer before deciding to change their name. I can use fulfillment to capture the raw API response and possibly get the last context however how can I force the user after changing their name to go back their previous context/intent?
You can do this easily by using the fulfillment. You have to save the previous intent contexts and prompt as well as the next intent contexts and prompt in the parameters of the intent.
I am writing you to ask a question about Dialogflow fulfillments.
I am trying to create an agent for Google Home and my backend is basically a web hook implemented in TypeScript.
In the conversation that I designed, the user requests to the agent to perform an action, providing a category as paramter. Now, the set of possible categories can vary through time, so I am using the entity type #sys.any to detect the parameter.
My problem is that, when on the fulfillment I try to identify the specific category on which the agent needs to take action, it may be the case that the requested paramter matches multiple cateogries, so I'd need a followup intent to ask the user to clarify which is the actual category it wants to select.
E.g. the conversation could be the following:
Agent: 'Welcome.'
User: 'Do action on **category**'
Agent: 'I have found **categoryA**, **categoryB** and **categoryC**. Please specify which one you want to select.'
User: 'Select the second || Select **categoryB**'
Agent: 'Great, action performed on **categoryB**'
Now, I was able to build this conversation using followup events and contexts: for example I created two followup events, one that detects the numbers and another that detects the text, so the user is driven on one or another depending on what it says (if the user says 'The first', a number is detected and in the backend I cycle the categories selecting the one that is associated to that index. I do a similar operation if the user says "categoryX", but inside a different intent).
What I want to understand is: what is the proper way to achieve that kind of conversation through the Node.js fulfillment API?
Thank you for any help.
From your description - you've done precisely the right thing (although you don't need followup intents).
When you reply with the options the user has, you include a Context that may contain the array of possible results. You then create Intents that have this as an Input Context, match either the index of the array (lets call this the match.index Intent) or by name (the match.name Intent).
In your webhook, the match.index Intent would determine which category was actually chosen, and then call a function that takes care of that category. Similarly, the webhook for match.name would take the parameter with the name and call the same function to take care of that category.
I'm new to dialogflow. In my default Hello Intent, I have something like this:
Good day! My name is xyz and I'm here to help you. May I know your name please?
This response is for when users say something like "hi"
After that, I will pass the context to another Intent to wait for the name input
I would like to avoid asking these information if I already have the user's contact information. Is there away to check for the context and trigger a different response?
If you just need to check if the context contains a property called "name" or similar, simply add a parameter in the second intent, set its value to #awaiting_contact.name and enable the mandatory option. That will let you define prompts if the property has no value, so you can re-ask the user.
However, I'm not sure what the Welcome Intent context has. You are just giving a welcome message. Then, when the user inputs his name, this will trigger a different intent.
In my dialogflow chatbot i am creating i have a scenario where a user can ask what are the available vacancies you have or they can directly ask i want to join as a project manager or something. Both are in the same intent called "jobs" and the position they want is a required parameter. If user don't mention the position (eg - "what are the available vacancies you have" ) it will list all available vacancies and minimum qualifications need for that vacancy and ask user to pick one (done with slotfilling for webhook.). Now since the intent is waiting for the parameter when user enter the position they like it will provide the details regarding that position. But even when user is trying to ask for something else (trying to call to a another intent or they don't have enough qualifications for that vacancy or the needed job is not listed with the available job list) since that parameter (the Job position) is not provided it ask again and again what is the position you want.
how do i call to another intent when the chatbot is waiting for a required parameter
There is a separate intent for "The job i want is not here". If i typed the exact same one i used to train that intent then i works. but if it is slightly different then it won't work
Try this:
make your parameter as "NOT" required by unchecking the required checkbox.
keep webhook for slot filling.
in the webhook, keep a track if the parameter is provided or not.
if the intent is triggered, check programmatically for parameter and ask the user to provide it by playing with the contexts.
if the user said something else, then there will be no "required" parameter as per Dialogflow and it will not ask repeatedly to provide the parameter.
Let me know if this helped.
Why does api.ai have context array, that creates contexts with some arbitrary names which live until the intent is complete?
When the intent is complete if a context is created it is retained rest others are removed, what is the significance of it
I assume you are referring to cases when you are in the middle of resolving an intent, you get context names that look like this: 72e79993-...-10dc7db59a93_id_dialog_context
This is happening because the intent has not yet been resolved, and the system creates a sort of temporary, interim context for any exchanges happening in this middle point, before the intent is resolved and export contexts are triggered.
In the cases you see it, you'll probably notice they're when the user has not filled in a required parameter values and API.ai has to respond with a prompt for the user to input their desired value. This 'prompt response' is a response but not a resolution of the intent. So to store/mark this temporary state as being different from a full response and resolved intent state (and to help interpret what the user says in this hyper-specific context of clarifying a specific parameter value given a specific intent), API.ai inserts these 'hyper-specific' interim context names.
You'll notice the context names in these cases match the metadata's intentID, for this very reason.