I'm creating a chatbot in Dialogflow in which the user is expected to enter a frequency of time, followed by specifying the time. i.e :
Bot: how many entries will you make on that day? (Or what so the frequency of your entries)?
User: Twice daily or two times a day.
Bot: Please enter those times.
User: 9 am and 7 pm
Now the problem is even if I enter more than two times it will still get accepted as the time by Dialogflow.
I need to implement a check here that will take only times if the user enters twice daily and accept three times if the frequency is thrice daily.
Is it possible to do this by manipulating entities and intents? I want to avoid doing this in the webhook.
Also the webhook I'll be implementing is in python. So can't use Node.js inline editor.
No, this can't be done in the Intents only. Remember that an Intent represents what the user has said, and not how you are using.
As you surmise, the best place to check these values are in your webhook fulfillment. Since you already have a webhook, it isn't clear why you are avoiding this.
In terms of design, you may wish to skip asking for the frequency and just ask the user to tell you when they'll be making the entries. You can then confirm that was all that they wanted, accept more if they needed more, etc.
Related
I am trying to make a search algorithm with dialogflow that could take any combination of: first name, address, phone number, zip code or city as input to a search algorithm. The user does not need all of them, but we will refine our search with each additional answer until we only have one result. Basically we are trying to identify which customer we are talking to.
How should this type of intent (or set of intents) be structured? We have tried one intent with multiple parameters, but we do not need all of them to be required. We have also written a JavaScript function for fulfillment but how can we communicate back to dialogflow as to whether we need more information?
Thank you very much for your help.
Slot filling is designed for this purpose.
Hope that helps.
Please post more code/details to help answers be more specific.
First, keep in mind that Intents reflect what the user is saying, and not typically what you're replying with or what other information you need. Slot filling sometimes bends this rule, but only if you have required slots.
Since you don't - you need a different approach.
This can be done with a single intent, although you may find that multiple intents make it easier in some ways. The approach is broadly the same:
When you ask the question, make sure you set an Outgoing Context with a relatively short lifespan (2-3 is good) to indicate you are collecting user info.
Create an Intent (or Intents) that have sample phrases that capture the information you need.
Some of these will have obvious entity types (phone number and zip code) while others will be more difficult (First name has a system entity type, but it doesn't include all possible first names).
You will need to create sample phrases that collect the parameters by themselves, along with phrases that make sense. You're the best judge of this, and you should probably write some sample conversations before you write the phrases.
In your fulfillment, you'll figure out if you have enough information.
If you do, you can reply and clear the Context that was set. (Clearing it is important so Dialogflow doesn't match the information collecting Intent again.)
If you do not, you can add the information you have as parameters to the Context so you can save it for later processing, make sure you reset the Context lifespan (so it doesn't expire), and prompt the user for additional information. Again, having a conversation mocked out ahead of time will help here.
I am trying out some things with Google Dialogflow. The thing I am basically trying to do is ask the user's age. Based on the age, say greater than 50 OR smaller than 50, I want the user to be guided to a specific question for one of the two age groups.
I was looking on the internet for a hint or suggestion, but I can't find examples other than "Yes","No" type of answers which then guide the user to a specific flow.
I basically need the user to say an age, which can be between 1-50 years, and 50-100 years, and any number belonging to any of the two groups should prompt the user to a specific follow-up question for that age group.
Does any one have a tip? Is this even possible in the generic Google Dialogflow? Or would I need to use a webhook/fullfilment for this?
Thanks and regards
The easiest way is to use fulfillment for this sort of thing. Dialogflow Intents are good at capturing what the user has said, and possibly including this as a parameter, but webhooks are best for applying logic and determining output and what context further answers should be considered in.
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.
In the chat application i am developing with dialog flow has scenario like this. Users can ask details about loans that they can get. that is a one intent. once user says the loan type they want i need to save it and use it every where when they ask question. for one example i have a another intent called loan payments.
In that intent they can ask questions like
I am interested in getting a personal loan for a duration of 5 years
and the loan amount would be 5 million rupees. Can you let me know the
monthly repayment amount?
to calculate that, loan type is a must (personal loan in this case). so if any user has specified the loan type before i need to use it here other wise i need to ask users to provide it again. but if i am using context i cant add add required. how to achieve this. also since i have already set the parameters i cant change the value of them. this is how my parameters look like
This is where your business logic comes in picture. Chat application can be built in two ways, directional & open-ended. In first one, you can explicitly go on asking few questions with set options/buttons for the services that you're offering & user has to select any one of them or in the second one, you keep it open for people to type-in anything & then you extract values & respond them based on their inputs.
Now that you're of second type, even if you use contexts, dialogflow offers you a favor to extract parameter values of first intent in the second one. You just have to use, #context_name.parameter_name. But now, if you're saying that if user has already defined loan type in earlier intent then you don't want to ask him again it in next intent, then this is purely a business logic that you will have to code in your webhook. Dialogflow won't do it for you.
I hope, this answers your question & if you don't want to do it that way, go for directional flow.
I have an intent with a simple slot filling question, which gathers a Number-Sequence of 4 characters long.
It looks like this:
The problems are as follows:
There are 3 different phrases defined under the slot filling list. (3rd image above). However, only the first one is prompted twice in a row by the system.
After the phrase is prompted twice, the system exits. I expect it to keep prompting the 3 different phrases round-robin style, until the user gets it right.
Is the maximum number of attempts specified somewhere? Can it be changed?
Can we make it use all of the slot-filling phrases, instead of just the first one?
First thing, if you say your verification code is 4-digit long, you should train your agent for 4-digit code only, I can see it in the first snap that you've trained it for 1-digit code only.
Anyways, now coming to your first question, The number of prompts that you have defined here are variations of each other. Api.ai will randomly select any one of them & send it as a response to the user. You do not have a choice to tell the system which one to be prompted first & which one to be second one neither you can define the cycle of prompts like round-robin.
Now, Answer to your second question, I have tried the same set-up at my end. It keeps on prompting unless & until it receives the correct code. Please check snaps. so, there is no limitation to the number of attempts you can have.