Dialogflow: Guide user to a specific flow depending on user's age - dialogflow-es

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.

Related

Restrict or handle user's asked queries in dialog flow

I have developed one Agent in DailogFlow. I want to restrict the user to ask any worthless queries to our system.
1). For this purpose, I want our intent will get hit only if the user's asked query length will be greater than 3 words else we'll simply say you can't proceed or please ask your question in detail.
2). We need to add one provision through which we can classify the abusive/defamatory/illegal words from the user's asked queries and stop it then and there.
Please suggest how can we achieve the above 2 items.

Manipulating Dialogflow intents/entities

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.

How to create a search form with dialogflow

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.

What is the best practice to create a Q&A Alexa app?

I want to make a simple Q&A Alexa app similar to Alexa's custom Q&A blueprint app. I don't want to use blueprints because I need additional functionality. What is the best practice for creating the Alexa app? Should I create a separate intent for each question or should I somehow use utterances?
The best way depends upon what the questions are and how it will be asked.
1. If the questions has a simple structure
Consider these examples:
what is a black hole
define supernova
tell me about milkyway
what is a dwarf star
then it can be configured like this in an intent:
what is a {space}
define {space}
tell me about {space}
and the slot {space} -> black hole, supernova, milkyway, dwarf star.
From the slot value, you can understand what the question is and respond. Since Alexa will also fill slots with values other than those configured, you will be able to accommodate more questions which follows this sentence structure.
2. If the question structure is little complex
what is the temperature of sun
temperature to boil water
number of eyes of a spider
what is the weight of an elephant
then it can be configured like this in an intent:
what is the {unit} of {item}
{unit} to boil {item}
{unit} of eyes of a {item}
what is the {unit} of an {item}
Here,
{unit} -> temperature, number, weight, height etc.
{item} -> sun, moon, water, spider etc
With proper validation of slots you will be able to provide the right answer to the user.
Also, you will be able to provide suggestions if the user asks a question partially.
Ex:
user: what is the temperature
[slots filled: "unit"="temperature","item":""]
Now, you know that the user asked about temperature but the item is missing, so you respond back with a suggestion like this
"Sorry I didn't understand. Do you want to know the temperature of the sun?"
3. If the questions has totally different structure
How to deal with an annoying neighbor
What are the types of man made debris in space
Recommend few good Nickelback songs
Can I jump out of a running train
If your questions are like this, with total random structure, you can focus on certain keywords or crust of the question and group them. Even if you can't group them, find out the required fields or mandatory words.
IntentA: How to deal with an annoying {person}
IntentB: What are the types of man made {item} in {place}
IntentC: Recommend few good {person} songs
IntentD: Can I {action} out of a running {vehicle}
The advantage of using slots here is that even if the user asks a partial question and an associated intent is triggered, you will be able to identify it and respond back with an answer/suggestion or error message.
Ex:
user: what are the types of man made mangoes in space
[IntentB will be triggered]
If you have configured this without a mandatory slot, your backend will be focusing on the intent triggered and will respond with the right answer (man made debris in space), which in this case won't make any sense to the user.
Now, with proper usage of slots and validation you can find that instead of debris your backend received "mangoes" which is not valid. And therefore you can respond back with a suggestion or error message like
"Sorry, I don't know that. Do you want to know about the man made debris found in space"
Grouping questions will help you to add other similar questions later with ease. You can use one intent per question if it is too difficult to group. But remember to validate it with a slot if you want to avoid the situation mentioned right above.
While naming question-intents use a prefix. This might help you to group handlers in your backend code depending on your backend design. This is not mandatory, just a suggestion.
Summary:
Group questions with similar structure.
Use slots appropriately and validate them.
Use predefined slots wherever possible.
Don't just depend on intents alone, because intents can be mapped if its the closest match. But the question might be entirely different or might not make any sense. So use slots appropriately and validate them.
If possible provide suggestion for partial questions.
Test thoroughly and make sure it wont break your interaction model.
You should check Alexa Dialog Interface that allow you to make Q/A or QUIZZ.
https://developer.amazon.com/fr/docs/custom-skills/dialog-interface-reference.html

how add a required filed to context parameters in dialog flow

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.

Resources