Let's imagine we are opening a restaurant. We use a chatbot to handle customer ordering.
Intent: #order
Entity: #food: burger, noodle, chicken #drinks: coke, water, wine #compliantItem: service, burger, chicken, noodle
Currently I put "I am thirsty, can I order a can of #drinks", and "I am hungry, can I order a #food" in the intent #order. Does any one know if this would confuse Watson?
I am wondering if this should be improved by
create a new entity called #menuItem and put 2 values food and drinks in it, while keeping entity #food and # drinks
create a new entity called #menuItem and put all values from #food and #drinks in it and remove entities #food and #drinks
maintain 2 intents: (1) #orderfood: put sample "I am hungry, can I order a #food" in the intent #orderfood and (2) #orderdrinks: put sample "I am thirsty, can I order a can of #drinks" in the intent #orderdrinks
Thanks a lot!
Your question is discussed in "How entity references are treated" in the IBM Watson Assistant documentation. You can reference entities as you did. It cancels out any specific examples.
I cannot comment on your intent definitions and improvements. It depends on your dialog flow and how the bot is used. It is learning from user input and how it is processed. If there is something wrong, you as admin can correct it and Watson Assistant would learn it.
Related
I'm trying to make a chatbot to allow users to book items. I have 2 departments with items, so I have made 1 intent for each department. Department A has boardgames, Department B has computer equipment.
I've set up my intents so a user can ask "I want to book Monopoly" or "I want to book a laptop" - those queries work.
Now, I want to be able to handle the user asking "I want to book a room". That query won't match any of the training phrases for either of the departments, but I do want to give the user a context-specific answer of "We don't have that item available".
How to I configure an intent to match "I want to book [noun]", where [noun] is an unknown thing?
We solved this by creating a Book "anything" intent. It uses the built-in #sys.any parameter. So we defined phrases like "I want to book #sys.any". This intent seems to be matched only if the intents for department A and B do not match. In this way, it is a fallback of sorts that matches for all booking questions for unknown "things"
Consider following sentences:
1) I want to watch movies watched by Srikanth but not by tarun
2) I want to watch movies of Christoper Nolan but not having Christian Bayle
3) I want watch movies watched by Srikanth but not liked by Tarun
The problem I am facing is -
Even though I can successfully define entities such as "not watched", "watched" , "not liked" , "having" , "not having" etc; etc;
Hence I will know what kind of action user is referring to.
I will also get to know names like Srikanth, Tarun, Nolan, Bayle etc;
But How do I establish Relationship between name and action. How do i know which action was related to which name.
I am not able to achieve this in LUIS / DIALOGFLOW.
What I feel is only way is to break statement into 2 distinct statements, How can we do that and is that a right approahc
We cannot directly assign multiple intents to the same utterance through LUIS. You can use NLTK along with LUIS to fix this issue as discussed here.
Another workaround is to create 2 apps with each intent and assign the same utterances and add the code which would differentiate the intent based on the keyword in the sentence.
Consider a scenario where user wants to order a meal :
User : I would like to order 1 burger 1 orange juice and one coffee
Bot : Would you like to have a veg burger or a non-veg one?
User: A veg burger
User: Sorry, I would like it to be non-veg
Bot: (Generally how would we handle this change of mind without having to start the conversation from scratch) ?
In this part where I've been implementing something like a bus ticket booking, this the bot seems to remember the previous order that is veg-burger or some how ends up falling on to default intent or fallback intent whichever is suitable. But I would like to know if there is a way for letting the bot know that the user has "Changed the mind" (Hopefully it is possible using or manipulating the context) and wants a non-veg burger now?
Can we work out an followup intent recognizing words like Sorry and then entity such as type i.e. non-veg here. What is the best practice? Because starting the conversation from scratch doesn't seem to be a good idea from UX point of view.
Good day TGW,
You have 2 options, either you split your intents into a search intent and book intent e.g. search.salad and buy.salad intents OR you have a confirmation step before you actually send to Fulfilment.
If you choose to split your intents into 2 then a similar flow should work for you:
If the food type is finite then create an entity with the options.
Add your search.salad intent that should have most of what the users will say to order a salad. Remember to incoporate the entity from step 1.
Add a followup intent to your search.salad Intent, and select custom from the options.
In this newly created followup Intent add the User says that you want to use to update the search, enable fulfilment and save.
NB: Ensure the newly created intent has an intent that ends with *-followup in the In-context and this same intent is in the Out-context of the search.salad intent. Dialogflow will automatically update the parameters for you based on what the user enters.
The second option is similar to this, you can add your confirmation step as a followup to the search.salad intent and enable fulfilment only on the confirmation intent.
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.)
I have been reading about Dialog Flow and there is one thing that is still unclear for me. I'll try to give an example.
I want to implement a conversion as following:
User: Hello Google, what are some interesting cities?
Bot: Hello there! Sydney, New York and Berlin are nice.
User: Could you tell more about the second city?
Bot: Sure. New York is amazing. In New York, you can ...
As you see, I am building a data context. After the first question, we should remember that we answered Sydney, New York and Berlin, so we understand what the second city actually means in the second question.
Should we store this data in the webhook service or is this stored in a context in Dialog Flow? If we have to store such data in the webhook service, how can we distinguish between different ongoing conversations?
Storing it in a Dialogflow Context is an ideal solution - this is exactly what Contexts were made for! You phrased your question using the same term, and this is no coincidence.
Conceptually, you might do this with a setup like this:
User: What are some interesting cities?
Dialogflow sees no contexts and matches an Intent asking for cities.
Agent replies: Sydney, New York, and Berlin are nice.
Agent sets context "cities" with parameter "cities" -> "Sydney, New York, Berlin"
User: Tell me more about the second one?
Dialogflow has an Intent that expects an incoming context of "cities" with a text pattern like "Tell me more about the (number index) one?" It sends the request to that Intent along with the currently active contexts.
Agent get a parameter with the index and the context "cities". It looks up the parameter for it, turns the string into an array, and gets the city based on the index.
Agent replies: New York is a fun place to visit!
Agent sets context "city" with parameter "current" -> "New York"
User: Tell me more!
Dialogflow matches this phrase and that the "city" context is still active and sends it to an event that reports more.
Agent says: More awesome stuff about New York.
User: Tell me about that first city instead.
Dialogflow matches it against the same intent as before.
Agent says: Sydney is pretty cool.
Agent changes the "city" context so the parameter "current" -> "Sydney" and "previous" -> "New York".
You can now create other intents that handle phrases like "Compare these two" or "tell me more about the other one".
Update
This setup strikes a good balance between what Dialogflow does well (parse messages and determine the current state of the conversation) and what your webhook does well (determine the best answers to those questions).
You could probably do much of that inside Dialogflow, but it would start to get very very messy very quickly. You would need to create multiple Intents to handle the results from each value individually, which doesn't scale. You'd also need to create a Context for each city (so you'd have a "city_ny" and "city_sydney" Context), since you can only match on the presence of a Context, not the parameters it might have.
Using the webhook (even the built-in fulfillment system that we now have) will likely work much better.