Is there any way to extract only parameter not the entity? - dialogflow-es

I have created an entity "editable" having entries as {name, age, color, place}
bot: select an option to update [options are {name, age, color, place}]
user: name
bot: enter your name?
user: Xyz
bot: record updated. select an option to update [options are {name, age, color, place}]
this works fine
but if a user says something like "my name is Xyz" to update the name.
bot: select an option to update [options are {name, age, color, place}]
user: name
bot: enter your name?
user: my name is Xyz
bot: enter your name.
as when the user includes "name" in his phrase then bot matches it with entity and again ask the same question.
how to resolve this issue, I just want to extract the "Xyz" though he uses the phrase "my name is Xyz".

You can use contexts to handle the flow of the conversation. Contexts are used to help dialogflow detect the correct intent. Output contexts are the contexts created after the intent was detected, and input context is a context required for an intent to be detected.
Think of dialogflow contexts, as the real context of a conversation, there are some phrases that you can expect after an interaction.
Here's an example using 3 intents for this conversation:
"Default welcome"
"Updating name selection"
"Updating name"
Conversation
Intent detected: Default welcome
Agent says: "Select an option to update [options are {name, age, color, place}]"
Output context: "select-option"
User says: "name"
Input context: "select-option"
Intent detected: Updating name selection
Agent says: enter your name
Output context: "update-name"
User says: "My name is Xyz"
Input context: "update-name"
Intent detected: Updating name
Agent says: "record updated"
In addition to this, there are follow-up intents which are used for this scenarios, one of the advantages is that in follow-up intents, the contexts are created automatically.
Parameters
You can get all the information to be updated within the same intent. For this, you can add the paramaters as required and take advantage of slot filling. Notice that you can specify the define prompts to be used when asking for these parameters.
You would need to add training phrases that help indetifying different parameters given:
During the conversation, when this intent gets detected, the agent will try to match all the required parameters, and will ask for missing information. At the end, you will have access to this information:
Consider that this kind of intents can quickly become hard to manage. Try using well defined entities for your parameters, and lots of training phrases (notice that in one training phrase you can collect more than one parameter, e.g., "My name is Xyz and I'm 27").

Related

How to provide dynamic answer for the selected entity as parameter in dialogflow fulfillment

I have an entity (items) and its values are ('name', 'colour', 'awards')
I have three intents
Intent1 = Welcome Intent (user will get the options in the form of chips)
Intent2 = Select Option (bot will ask question to enter detail for selected option)
Intent3 = Update Option (bot will save the record and ask next option to update.)
Example -
bot: welcome! what you want to update? name, colour, awards.
user: name
bot: Enter your name.
user: John
bot: record updated, what to update next? name, colour, awards.
now the issue is awards have multiple fields to update, to update awards a user has to provide three things (award name, award date, award description)
What I want is when a user selects awards options from the chips then it should be taken to new intent where I will get all the data through slot filling.
The first thing to remember is that an Intent represents what the user has said and not what you are doing with what they have said. So it doesn't make sense to say that you are "going to an Intent".
Second, while slot filling seems like a good idea, it usually leads to further problems, since it doesn't handle conditional information well, or handle users if they skip around in what they want to update.
All of these are better solved by setting up a state machine where they are in the conversation, what information you need, and what they have provided so far. Based on these settings, you can prompt them yourself for what you expect next. (You may also find using one or several Dialogflow contexts useful for shaping how to accept results as well.)
So, for example, when the user has indicated they are updating the awards, it might work like this:
User: Awards
[Your fulfillment sets the 'awards' context with a parameter that we are prompting for the name.]
Bot: Ok, I'm going to need the award name, description, and when it was awarded. What is the name?
User: Merit
[This matches the Fallback Intent with an Input Context for 'awards', since it is free-form input. Your fulfillment stores this and sets the 'awards' context with a parameter that we are now prompting for the date.]
Bot: Got it, the award is named Merit. When was it awarded?
User: Today
[This matches an Intent with a training phrase of "<#sys.date>" and the Input Context of 'awards'. There are also training phrases for things like "It was awarded <#sys.date>" and so forth. Your fulfillment sets the date and sets the 'awards' context with a parameter that we're now prompting for description.]
Bot: Got it. Awarded on March 1st. What is the description?
User: They were awesome.
[This matches the Fallback Intent with the Input Context of 'awards' again, because it is still free-form input. Our fulfillment, however, knows that this is about the description this time, so it stores it and removes the 'awards' context since we've captured everything.]
Bot: I've recorded that as a description of "they were awesome" - sure thing. That was everything we needed for now. Do you want to update the name, colour, or awards next?
That all seems pretty straightforward. But consider if the conversation had gone this way:
User: Awards
[Your fulfillment sets the 'awards' context with a parameter that we are prompting for the name.]
Bot: Ok, I'm going to need the award name, description, and when it was awarded. What is the name?
User: [Having done this many times] They were given the award for Honor yesterday
[This might match an Intent with an Input Context of 'awards' and the training phrase of "Given the award for <#sys.any> <#sys.date>" and possibly "<#sys.date> they got an award for <#sys.any>". Your fulfillment sets the name and date from this, sees what information it still needs, and prompts with...]
Bot: Got it. Award named Honor. Awarded March 1. What is the description?
User: Actually, it is named Honorable Service
[This matches an Intent with a training phrase of "named <#sys.any>" and an Input Context for 'awards'. Your fulfillment changes the name stored, checks what we still need, and again prompts...]
Bot: Ok, I've changed the award name to Honorable Service. What is the description?
The first scenario could be handled by slot filling and simple prompting, but the second can't. Being able to handle more natural responses from people and more flexible prompting will be better for your users.

Dialogflow regain the context after slot filling is canceled with out all the required parameters/slots filled by user

We are trying to build a chatbot for vehicle dealerships. When a user asks for queries like "I am looking for ford 2017 models" etc we have some more slots to fill before we show the user final results. So to handle this we have created an intent with required parameters. We are also providing some custom UI buttons to help the user with the slot filling process. However some times users can choose to give their own input and some times users can enter text other than the slot value.
For example:
User: I am looking for ford latest models 2017 or afterwards.
Bot: Which model are you looking for: We display some options
User: escape
Bot: What is the price range you are looking for: We display some options
User: I looking for something which will suffice for a family of 4.
Here, in this case, the slot filling is broken as the user didn't give the expected slot/parameter. Also, it would be good user experience if we can somehow reply to such human nuances and continue with the slot filling.
EDIT:
We have already incorporated some mechanism during slot filling to handle the cases where the user enters some input other than required slot value. But sometimes this mechanism is not working and some times user might enter a statement which triggers new intent.
How can I handle such cases using dialogflow?
I would recommend not using Dialogflow's built-in slot filling. I've had this issue before and now I just create different intents for each 'variable' I want to gather from the user.
You could still use slot filling if you let the user know what format you're expecting them to answer in. The KLM chatbot does this perfectly, you should check that out.
UPDATE: Here's how you could handle input for different parameters. Whenever a user responds something you don't expect the 'question.invalidInput' will be triggered and there you can remind the user what format you're expecting.
Intent: question
Trainings phrase: 'May I enter?'
Output context: 'await_olderThan21'
Response: 'Are you older than 21?'
Intent: question.yes
Training phrase: 'yes'
Input context: 'await_olderThan21'
Output context: ''
Response: 'Yes, you may enter'
Intent: question.no
Training phrase: 'no'
Input context: 'await_olderThan21'
Output context: ''
Response: 'No, you may not.'
Intent: question.invalidInput
Training phrase: #sys.any
Input context: 'await_olderThan21'
Output context: 'await_olderThan21'
Response: 'Invalid answer. Please reply with yes or no.'
E.g.:
User: I am looking for ford latest models 2017 or afterwards.
Bot: Which model are you looking for: We display some options
User: escape
Bot: What is the price range you are looking for: We display some options
User: I looking for something which will suffice for a family of 4.
Bot *fallback*: Please enter the maximum amount you would like to spend on a car (in dollar)
This way the user knows how to respond and you will notice that you will experience less expected behaviours.
Always try to guide the user in your desired direction.
Hope this helps!

how to handle the wrongly capture input from user in dialogflow?

I have created a chatbot using dialogflow using four intents and I am passing contexts form one intent to another intents .
welcome intent
GetName intent
GetEmail intent
GetDOB intent
I wanted to know how to call fallback intent if user entered wrong name. It should call GetNameFallback intent , for wrong email it should call GetEmailFallback intent. For wrong DOB it should call GetDOBFallback intent.
For each specific intent it should call its specific Fallback intents
Here is the list of contexts I am passing:
(welcome intent) - output context : awaiting_name
(GetName intent ) input context : awaiting_name and output context : awaiting_email
(GetEmail intent ) input context : awaiting_email and output context : awaiting_dob
(GetDOB intent ) input context : awaiting_dob
From the Dialogflow docs: "When you create an agent, the Default Fallback Intent is automatically configured with a variety of static text responses, like "I didn't get that. Can you say it again?" and "Sorry, what was that?" This intent is matched when your user's input does not match any other intent; in other words, it's a kind of catch-all for any unrecognized user input.
For example, say that your agent has only one custom intent named weather that recognizes user input like "What is the weather today?" or "Forecast tomorrow". If a user speaking to your agent says "I like the color purple", your Default Fallback Intent is matched because the agent isn't able to match the input to the weather intent."
Based on that information, you might try training your agent to match an incorrect name / email to an intent like Fallback Intent - Name or Fallback Intent - Email, where those intents reprompt the user for the name again.
Without seeing your fulfillment code, it's hard to say for sure whether or not this strategy will work. If you update your question to include your current fulfillment code, you might get a more relevant answer.

Google Assistant - how to re-prompt the user with #sys.any when an input is determined to be invalid

I'm trying to create a custom action through Google Assistant. I have custom user data which is defined by the user and I want the user to ask me something about this data, identifying which data they want to know about by supplying it's name.
ex:
User says "Tell me about Fred"
Assistant replies with "Fred is red"
[
{
"name":"Fred",
"info":"Fred is red"
}
]
The problem I'm having is how to add a Training phrases or re-prompting for the user to use when they supply a name which doesn't exist.
ex:
User says "Tell me about Greg"
Assistant replies with "I couldn't find 'Greg'. Who would you like to know about?"
[
{
"name":"Fred",
"info":"Fred is red"
}
]
I've tried adding a Training response which only contains the 'name' parameter, but then if the user says "Tell me about Fred", the "name" parameter is set to "Tell me about Fred" instead of just "Fred", which means it ignores other Training responses I have setup.
Anyone out there who can be my Obi-wan Kenobi?
Edit:
I've used Alexa for this same project and have sent to Alexa an elicitSlot directive. Can something similar be implemented?
There is no real equivalent to an elicitSlot directive in this case (at least not the way I usually see it used), but it does provide several tools for accomplishing what you're trying to do.
The general approach is that, when sending your reply, you also set an Output Context with the reply. You can set as parameters for the Context any information that you want to retain (what value you're prompting for and possibly other state you've already collected).
Then you can have Intents that have this context set as an Input Context. The Intent will then only be matched if the Context is active. This Intent can match #sys.any, or whatever other Entity type might be appropriate in this case.
One advantage of this approach is that it allows for users to reply more conversationally, or pivot their reply away from the prompting question you've just asked. It allows for users to answer within the Context, or through other Intents that you've already setup for other purposes.

Dialogflow(Api.Ai) Doesn't recognize custom entity

I have been working lately with Dialogflow to make chatbots to do some simple tasks. For instance with webhooks and youtube api where the user ask to show him a video and then the bot just answers with the youtube video url.
E.G.
USER SAYS
Show me Neil young harvest moon
AGENT SAYS
Here you go : https://www.youtube.com/watch?v=n2MtEsrcTTs
I do this by using a custom Entity I called "YoutubeQuery" I checked "Allow Automated expansion" and unchecked "Define Synonyms" then I just added 2 values "Kavinsky Night Call" and "Indigo Night Tamino"
In my Intent I just made a couple of training phrases like these:
And everything works.
Now my issue is with a new Agent which I called Orders
I want just to get Order Id's from the firestore database, but before getting there I'm running in kind of a huge problem
I defined the order's ID entity just like the one with the youtubeQuery. And I added some example Order ID's , I want them all to Start with OD and have 4digits after example (DX0001,DX0009,DX9999)
Afterwards I made the intent
Now unless I give the EXACT order ID's from the traininphrase or the ID examples I defined in the Entity it will always give me a response with an empty parameter OrderID
I start my intent by saying "my order" then I get prompted with "What is your ID?
So when I give an ID that has not been used in the training phrases of the Intent I get an empty value in the parameters like this:
But when I give an ID that has been used in the training phrases like for instance the first one DX0808 it does work...
How can I make this work without adding all the possible order id's ranging from DX0001 to DX9999 in the training phrases or the entity.
I mean it does work for my youtube query, I can put anything there it does "catch" the value. Any help please?
It looks like the required parameter is the problem here, my suggestion would be to:
Create intent to get the order id in one sentence without reprompt (turn off required on the order id) and id is always present, ex: "my id is DX0402". Include training response where only ID is provided like "DL3932", ex. below:
Set other intent for scenario when customer wants to provide the id but it is missing, for ex. customer says: "my id" and make your bot ask for the id as an response ex. "ok, provide me your id"
If you do it, in case user doesn't provide the id, intent 2 will be triggered and after id is provided you'll trigger intent 1.
Hope this makes sense.

Resources