Dialogflow address triggering wrong intent - dialogflow-es

I've got a order flow that I've setup. I have one intent to get quantity and then I have another to get address. I have the address entity to start by asking for a zipcode/postcode and then a follow up to ask for house number/name.
When I ask for the house number or name my parameters entity is set to sys.any. Because we may get just a house number but could also get something like 'Hill Farm' or 'Flat 4b'. The issue is that when the user inputs a number it actually goes back and triggers the quantity intent which is a #sys.nymber-integer entity. I thought the follow up intent would keep it focused on looking for a house no/name.
I've carried the context along from the quantity question thinking that it won't ask for it again but it still does so.
I've changed the entitys from sys.any to sys.number-integer for $houseno and sys.any for $housename. However entering a number still triggers my quantity intent. Anyone have any ideas?

The solution is to use Context to instruct DialogFlow.
Step 1:
For the Address Intent train the intent with all the User says data that you have and set an Out-Context - e.g adress-data. Add another intent that will capture house number and then add all the User says entries as usual. However also set the In-Context to address-data
Step 2:
Create your Quantity Intent as you have now and save.

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.

Using #Sys.Any Entity For my Chat bot / Assistant Service(Design Issue)

I am trying to develop a chatbot / google assistant service for food ordering service, and I currently have it designed this way:
There is a dynamic menu list that will be fetched through an API every time the user asks for menu (new Order Intent)
Then menu categories name list will be displayed
Then the user sends the category name
The second follow up intent (selected category intent) catches it and fetches the food items in the category
Then user sends the food item name
Then next follow up intent (selected item intent) catches it and asks for quantity.
The problem here is since it is dynamic list I can not make use of custom entity and slot filling and train it, so i am currently using #sys.any entity. getting the category name from user and checking if it is present in the menu list from the webhook, if present display item list. if not present check spelling or enter correct menu category and reenter prompt. then here since the "selected category intent" is already consumed so whatever i type now is taken as "item name" instead of "category"
I am preventing this by matching output context from "selected category intent" fulfillment and input context in the "selected item intent". But there are problems with this approach such as once a category is selected I can not go back and change that, and it only works 5 times(lifespan of parent intent context) before going to fallback intent
I know this is really bad design but is there any way to make this better?
Any way to say if the user enters a wrong category name, no do not consume this intent yet go back and get the right category name?
Or if the user selects a category or item by mistake. any way yo go back to that previous intent and do that again?
A few observations that may help:
Use Session Entities
Since you are loading the categories and menu dynamically, you can also set Entities for these dynamically. To do this, you'll use Dialogflow's API to create Session Entities that modify the Entity you have defined. Then you can train your Intent with phrases that use this Entity, but you'll dynamically modify the Entity when they start the conversation.
Don't use Followup Intents
Followup Intents are useful in very limited circumstances. Once you start chaining Followup Intents, it is usually a sign that you're trying to force the conversation to go in a particular way, and then you'll run into problems that you have when the conversation needs to take a slight turn.
Instead, go ahead and use top-level Intents for everything you're trying to do.
"But," I hear you asking, "How do I then make sure I handle the category selection before the menu selection?"
Well, to do that you can...
Use Contexts
You were on the right track when you said you were matching Output Context. You can not only match it, but go ahead and control which Contexts are set in your webhook. So you can use Input Contexts to narrow which Intent is matched at any state of your conversation, but only set the Output Context in your webhook fulfillment to determine which Contexts are valid at any stage of the conversation. You can clear Contexts that are no longer valid by setting their lifespan to 0.
So under this scheme:
When you tell them the categories, set the "expectCategory" context.
The "selected category" Intent is set to require the "expectCategory" Input Context.
In the handler for this context
You'll tell them the menu
Set the "expectMenu" context
Clear the "expectCategory" context
Most of all, remember...
Intents represent what the user says, and not how you react to what they say.

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.

Dialogflow fulfillment chose among options

I am writing you to ask a question about Dialogflow fulfillments.
I am trying to create an agent for Google Home and my backend is basically a web hook implemented in TypeScript.
In the conversation that I designed, the user requests to the agent to perform an action, providing a category as paramter. Now, the set of possible categories can vary through time, so I am using the entity type #sys.any to detect the parameter.
My problem is that, when on the fulfillment I try to identify the specific category on which the agent needs to take action, it may be the case that the requested paramter matches multiple cateogries, so I'd need a followup intent to ask the user to clarify which is the actual category it wants to select.
E.g. the conversation could be the following:
Agent: 'Welcome.'
User: 'Do action on **category**'
Agent: 'I have found **categoryA**, **categoryB** and **categoryC**. Please specify which one you want to select.'
User: 'Select the second || Select **categoryB**'
Agent: 'Great, action performed on **categoryB**'
Now, I was able to build this conversation using followup events and contexts: for example I created two followup events, one that detects the numbers and another that detects the text, so the user is driven on one or another depending on what it says (if the user says 'The first', a number is detected and in the backend I cycle the categories selecting the one that is associated to that index. I do a similar operation if the user says "categoryX", but inside a different intent).
What I want to understand is: what is the proper way to achieve that kind of conversation through the Node.js fulfillment API?
Thank you for any help.
From your description - you've done precisely the right thing (although you don't need followup intents).
When you reply with the options the user has, you include a Context that may contain the array of possible results. You then create Intents that have this as an Input Context, match either the index of the array (lets call this the match.index Intent) or by name (the match.name Intent).
In your webhook, the match.index Intent would determine which category was actually chosen, and then call a function that takes care of that category. Similarly, the webhook for match.name would take the parameter with the name and call the same function to take care of that category.

Dialogflow required parameters

In my dialogflow chatbot i am creating i have a scenario where a user can ask what are the available vacancies you have or they can directly ask i want to join as a project manager or something. Both are in the same intent called "jobs" and the position they want is a required parameter. If user don't mention the position (eg - "what are the available vacancies you have" ) it will list all available vacancies and minimum qualifications need for that vacancy and ask user to pick one (done with slotfilling for webhook.). Now since the intent is waiting for the parameter when user enter the position they like it will provide the details regarding that position. But even when user is trying to ask for something else (trying to call to a another intent or they don't have enough qualifications for that vacancy or the needed job is not listed with the available job list) since that parameter (the Job position) is not provided it ask again and again what is the position you want.
how do i call to another intent when the chatbot is waiting for a required parameter
There is a separate intent for "The job i want is not here". If i typed the exact same one i used to train that intent then i works. but if it is slightly different then it won't work
Try this:
make your parameter as "NOT" required by unchecking the required checkbox.
keep webhook for slot filling.
in the webhook, keep a track if the parameter is provided or not.
if the intent is triggered, check programmatically for parameter and ask the user to provide it by playing with the contexts.
if the user said something else, then there will be no "required" parameter as per Dialogflow and it will not ask repeatedly to provide the parameter.
Let me know if this helped.

Resources