Is it possible to set fallback intents using only contexts?
The example would be the user asks a question which triggers fallback intent 1 "sorry I don't understand"
The user then tries again with a reformulation of the question which then triggers fall back intent 2 "hmmm I still don't understand you, please leave your email and someone will get back to you right away"
I have tried adding contexts but it is always the default fallback intent that is triggered
You can use fulfillment code to give response like that.
For this you need to set a counter for fallback occurance.
then according to counter variable you can reply with different text each time fallback has occured.
Related
I have a bot that answers question related to a certain topic. However, the user may say something that doesn't match with any intent I have. This phrases need to be stored on a database.
So far, I found out that I need to create a fallback intent. How can I make it so upon being triggered this intent returns a response with the text that triggered the intent?
Also, if I only have one fallback intent, will every missed match trigger it or do I have to link it in some way to all my intents?
The easiest way to do something with the user input in a Fallback Intent is through your fulfillment webhook. In the request object that is sent, you can look at the queryResult.queryText parameter to get the text from the user. You can then send this as part of your response as part of the fulfillmentMessages object.
You can't "attach" a Fallback Intent to a regular Intent. That doesn't actually make sense, since Intents represent what a user says, rather than the state of the conversation.
While there is a single Fallback Intent available, which can catch all no-match phrases, it is also possible to create Fallback Intents that only trigger if specific input contexts are set. If you have regular Intents with these same input contexts set, then the Fallback Intent with the context would catch anything they don't.
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 have created a google action, which takes in three parameters, I have done training phrases for many word combinations, but sometimes it will not pick it up.
I set my input parameters in the dialog flow to number1, number2, and number3.
It seems by default, if it misses a value it will say: "what is $varName"
however, this could be misleading to users since it may be unclear if it just prompts the user for 'what is number3'.
Id like to edit this response to be a more descriptive message.
I hope this is clear enough - I cant really post any code since its all concerning this dialogflow ui...
cheers!
If you want to add prompt variations for capturing parameters in an entity follow the "adding prompt variation" explained here. Just add variations to prompts as below or handle it from webhook by enabling slot-filling for webhook.
If you want to ask questions when the agent did not understand the intent then you can either use a Default Fallback Intent for a generic reply or create a follow-up fallback intent for the intent you are targetting.
or
Not much to add to this question I don't think. Basically, I have a series of questions the user needs to answer, but they are veeeery open-ended, so the user input could be pretty much anything. Once the user responds to a question I want the system to simply ask the next one, regardless of what they said (unless they say something like "help" or "I don't understand", etc, which I can deal with).
I know I can include contexts, but without supplying the next intent with adequate user input, there doesn't seem like a way to get it to trigger the next question (even when the output and input contexts match).
Is there something I'm missing, or do I really need to just supply dozens and dozens of potential user inputs from across the board and hope the machine learning component extrapolates adequately?
For open-ended responses, the easies way to handle this is through Fallback Intents. You can create more than one Fallback Intent - but each one needs to have a different Input Context which will indicate under what conditions it will be triggered.
To be clear - Fallback Intents are slightly different than regular Intents, and you create them slightly differently as well. In the most simple configuration, they are only triggered if the user input does not match the input for any other Intent. Dialogflow provides a "Default Fallback Intent", which is what will be triggered if no other Intent of any sort matches. You'll need to set the Input Context of your Fallback Intents to indicate when it should handle it with that Fallback Intent and then also set the Output Context to indicate which question you have asked and, therefore, what the next expected Fallback Intent will be.
To create a Fallback Intent, don't click on the "Create Intent" button, instead, click on the three dots next to it.
In the menu that appears, click "Create Fallback Intent"
The screen that shows is very similar to a regular Intent editing screen, but it is specifically for Fallback Intents. You'll do the usual things about adding the name and (not shown) showing the replies (ie - the next questions you'll be asking).
You can tell it is a Fallback Intent because of the message at the top. As noted, you should then enter the Input and Output Contexts you plan to use for this.
You will notice there is a "Training Phrases" section. In your case - you will leave this blank. These are actually Negative Training Phrases - phrases that will not match other Intents (even if they should) and will always be handled by the Fallback Intent instead. Since you aren't trying to mask out phrases that might match elsewhere - leave it blank.
I have a conversation with dialogflow to select a favourite type of drink and then depending on the category of drink there are follow up questions (ie follow up intents).
Under the intent tab I have the following intents:
Default Welcome Intent
Favourite drink Intent
Coffee Intent
follow up
Soft Drink Intent
follow up
Juice Intent
follow up
I use the training phrase in the Favourite Drink Intent and ask:
"What is your favourite drink?"
And store the response in an entity #drink.
But I don't know how then to trigger the intent "soft drink", "juice" or "coffee" intents depending on the users response. If I was writing code I'd use a switch statement or if/else but that prob doesn't apply here.
I wasn't sure if I had to use the fulfillment inline editor or I could just do that from within the Intent UI.
Thanks
In general - think of Intents as capturing what the user could be saying. Although Intents also have replies, this isn't their primary purpose.
Depending what, exactly, you're trying to do, there are a few approaches. All three of them require fulfillment code, which you can do using the built-in editor, or (better) use a webhook more under your control
If you want to use Intents to determine how to reply
This isn't really the best idea, but it is possible. In your fulfillment code, you would have a switch statement against the parameter with the user's selection. Based on this, you would trigger a followup event from your fulfillment. Your other Intents would have the Event section populated with the possible events, and the system would pick which one to trigger and use for fulfillment/response.
This is a bit of a kludge for what you want, probably.
Update to clarify based on questions in the comments. Sending an event directly triggers a different Intent. Sometimes this is what you want, but it is somewhat exceptional. Most of the time you want to use one of the methods below. In particular, you should remember that Intents are mostly meant to represent what the user is trying to do (what they "intend" to do), and this is mostly represented by what they're saying. Intents are good to capture the complex ways people talk instead of forcing them into a phone-tree-like "conversation".
If you just want to reply to each possible user response differently
You can use the fulfillment webhook code to determine what response should be sent to the user. You don't indicate what library you're using, but in general you'd write code that would determine what message should be sent to the user based on the drink type selected and include that as the speech and/or display text in the response.
You wouldn't use the other, drink specific, Intents in these cases. There isn't any need for them. Unless...
You want to reply to each user response differently, and the followup conversation might be different
Remember - Intents are really best for specifying what you expect the user to say. Not what you expect to reply with. So it is reasonable that you may have a different conversation based on if they selected Coffee (where you might ask how much sugar they want) or Juice (where you might ask if they want a straw).
In this case, you would still do as you have in the previous case (use your fulfillment to include a tailored message in your reply, possibly to prompt them for that info) and include in the reply an Output Context indicating what their choice was. You should do this as part of the response, rather than setting it in the Intent, since you'll want to name it differently for each beverage type.
Then you can create Intents specific to each beverage type with what you expect the user today. For those specific to Coffee, you would set the Input Context to require that the coffee context has been set. The soda context if they specified soda, and so forth.
Update, since you indicated in your comment that this sounded like the avenue you were interested in.
In this scenario, you'd do as you described (almost):
Get the value for the drink parameter with code something like
const drink = request.body.queryResult.parameters.drink;
Do a switch based on this, and in the body of each case set what we'll reply with and what context we should remember. Something like this pseudocode, perhaps:
switch( drink ){
case 'coffee':
context = 'order_coffee';
msg = 'Do you want sugar with that?';
break;
case 'soda':
context = 'order_soda';
msg = 'Do you want a bottle or can?';
break;
case 'juice':
context = 'order_juice';
msg = 'Would you like a straw?';
break;
}
// Format JSON setting the message and context
You would then have Intents that would be triggered based on a combination of two things:
What the context is
What the user has said
For example, you would want a context (let's call it "coffee.black") which would be triggered if the order_coffee context is active and the user answered your question with "No" or "Just black" or other valid combinations.
But you'd want a different context (say, "juice.nostraw") if the order_juice context is active and the user replied "No".
And it wouldn't make much sense at all if the user said "No" while the order_soda context was active, so you'd want to try and direct them back to the subject at hand.
Remember, the Intent is for what the user says. Not for what your voice agent is saying. Your agent doesn't normally "trigger" an Intent - the user triggers it based on what they say.
In the example I gave, there might be other Intents that are valid for each of those contexts. For example, you might have a "coffee.sugar" Intent that is valid for the order_coffee context and responds to them saying "Yes". And another one where they might say "Just cream". There are lots of other things they might say as well, but it is important to your agent that the directions they're giving you have to do with ordering coffee.
As for your original question...
(To answer your original, now edited, question: Yes, you can create Intents from within your fulfillment. You almost certainly don't want to do this, however.)