I want to capture free speech from the user in Dialogflow.
Let's imagine the following conversation:
User: I want to order a pizza
Agent: What type of pizza would you like to order?
User: Chicago Pizza.
Agent: What time works best for you?
User: 6 PM.
Agent: Okay, would you like to add a note to the restaurant?
Yes -> User: Yes, please.
Agent: Please, tell me your note
User: <Free speech, user may say whatever he/she wants or feels necessary for his/her order>
Agent: Copy that. You ordered a Chicago pizza and it will delivered at 6 PM. We have also sent your note to the restaurant.
No -> User: No.
Agent: Okay, you ordered a Chicago pizza and it will delivered at 6 PM.
How can I receive or capture that sort of speech from the user?
You can use #sys.any entity. Use follow-up intent with sys.any if user says yes after Agent: Okay, would you like to add a note to the restaurant? . You can get free speech as string by doing this and use it as note.
Also, you may consider to look here:
Agent Design
Related
How to handle multiple confirmation prompts:
use case, 1st prompt is to ask would you like to add more products?
if yes, should repeat the intent to take more products and quantity,
if no, should ask for confirmation- Shall I place an order? -> if yes, make an order, if no -> cancel
Short answer: use sessionAttributes
‐------------
Long answer with a tip:
If you must do it this way, you should probably use a single intent, but re-elicit the same slot multiple times.
You should probably also ask beforehand how many products they want to list, so you can ask for that many things before expecting to confirm instead of asking if they want to add another product every time.
Let's say you have a Pizza Ordering Bot. For toppings, it could be like this.
Bot: What topping would you like?
User: Cheese
Bot: Would you like another topping?
User: Yes
Bot: What topping would you like?
User: Peppers
Bot: Would you like another topping?
(...again and again, unnatural)
So that would be more natural if you changed to:
Bot: How many toppings would you like?
User: 3
Bot: OK, what is the first topping?
User: Cheese
Bot: Got it, what is the second topping?
(much shorter, more natural)
In both cases, you would have a single slot for toppings, and every time you collect 1 value, you would copy that value into the bot's sessionAttributes and erase the slot from the slots object that you return to the bot when you ElicitSlot for the same slot.
Then when the user confirms that they are finished giving you all of the "toppings" or products they want, then you can combine all of the previous values from your sessionAttributes and fulfill the intent.
I have two intents pizzaSelected and burgerSelected in both intents I am asking for required parameters
I have below entities
#pizza [pepperoni, farmhouse, country special, cheese]
#pizzaSize [small, medium, large]
#burger [veg, beef, ham]
#burgerToppings [onion, tomato, lettuce, pepper]
expected conversation
user: order 2 burgers
bot: which burger?
user: cheese
bot: sorry but we have veg, beef and ham burgers. please select one from this.
user: veg
bot: toppings?
user: tomato and lettuce
bot: you order for 2 veg burgers with tomato and lettuce toppings is placed.
actual conversation
user: order 2 burgers
bot: which burger?
user: cheese
bot: what size of pizza you want
as in actual conv when user says cheese which belongs to #pizza entity then it triggers the pizzaSelected intent instead of re-prompting the user for entering correct value.
Is there a way to handle this.
If you are not using custom fulfilment based logic for slot filing then your burger_type entity (or whichever name you might have used for entity) must have cheese as a valid value.
I would recommend to go to entities and check the values of entity which you are using to store type of burger. Even if you have only the correct values there try reordering them and then save. This will force the bot to retrain as this is a machine learning model sometimes it might get optimized for the wrong output, if that is the case for you then try retraining it.
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.
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!
There are two loops here:
Re-prompt from DialogFlow when user is not entering correct value for slot
eg.
Bot: What is color of your car?
User: potato
Bot: What is color of your car?
User: tomato
Bot: What is color of your car?
...
Getting fallback intent replies from DialogFlow
eg.
Bot: What is your car brand?
User: red
Bot: Sorry, could you rephrase.
User: red red
Bot: I did not understand, could you say it again.
...
How to come out of these scenarios? There is no provision of setting number of re-prompts.
Thanks to #Abhinav, I got one approach of using outputContexts to solve this issue, however I am getting many cases to get this working as described in below pic:
But I am getting confused whether I should increment the counter or decrement it. As output contexts also gets decrement with every call.
You need to maintain that by yourself. For Action on Google you can look into following example https://developers.google.com/actions/assistant/reprompts
For Dialogflow:
Create a parameter, "re-prompt"
Check it in fallback intents.
increment it in fallback.
reset or decrement it in other intents.
if it is greater than 2, you may exit the conversation by letting the user know that you are unable to process at this time.