Dialogflow slot validation from database - dialogflow-es

I want to validate my slot from database.
I train bot to identify entity name and return as parameter personName
User phrase - tell me details of Mr.Jhon
In above phrase "Jhon" will be identified as personName, now this parameter is passed to webhook for validition from database.
If database have more than one entries for name "jhon"
Response will be - I found follow persons with name jhon -
jhon abc
jhon xyz
Kindly tell whose details you want?
Now here, when I entered anyone option form given set of entries,
Bot response is - Sorry, I missed that
conversation is as follows -
user - I want details of Mr.Jhon
Bot - I found various person with name Jhon -
1. Jhon abc
2. Jhon xyz
3. wxz Jhon
whose details you want?
user - Jhon abc
bot - sorry, I missed that
I use flask (python) for webhook development

Related

how to give quick replies (Dialogflow) using spring java?

I want to respond with quick replies to webhookrequest(Dialogflow) using java spring. I had create a chatbot for Slack using Dialogflow. I want to add content as response which is dynamic which means I cant always go and add the content manually through Dialoglfow console. So I thought of using quick replies but how should I implement it with java spring?
I want it in this way:
U: what is the total cost
Bot: For which account:
1. ABC
2. PQR
3. XYZ
U: clicks option 1 ABC
Bot: Total cost for ABC is xxx

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

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").

How To Handle Homonyms

I am in the process of creating an agent that will handle call requests via speech. For example, here is what the flow looks like:
1). User says: I need to call John
2). The agent grabs John as the parameter and via fulfillment it queries a database for all the entries that contains John in a certain field. If there is more than one John, a follow up intent is triggered and sends a response asking which John is the desired one:
Agent says: There are several Johns, who do you wish to call? John Test, John Smith, John Pleis or John Schmidt?.
3). The user wants to get in touch with John Pleis.
User says: John Pleis
Here is where I'm having problem. Dialogflow is recognizing John Please, instead of John Pleis. How can I handle this?
Update
Here is how the intent looks:
-- INITIAL INTENT --
-- FOLLOW UP INTENT --
You should be able to address these by using your own Entity Types for the names instead of using the System Entity Type of #sys:any. This lets you specify the possible names that would be accepted and Dialogflow can work with the assistant to better understand what the user might be saying. This isn't perfect, but can improve phrase detection, and can provide you with some tools to help it out to make detection even better.
If your directory is relatively small (a few hundred people, perhaps), you can simply create Developer Entity Types up front for all the names. (There is even an API for managing these Entity Types, so you can automate it.)
If you have too many names, you may want to just create Developer Entity Types for the possible first names (or use the System Entity Type of #sys:given-name if that is suitable enough) and then, as part of your fulfillment webhook, populate a Session Entity Type with the possible names that match.
In either of these cases, you can also use entity aliases to help improve matching. So if you see that "John Please" is still matching, then you can set this up as an alias for "John Piels" and Dialogflow will report this as "John Piels" for that Entity.

How do I get a users response in Dialogflow

How do I get the users response from a question asked to the user and display the response in fulfillment?
Example:
Google Assistant: What is your name?
User: My name is Yuri Alves
Google Assistant: Hello, Yuri Alves
Here is the simplest way to achieve this:
Setup an intent with the response What is your name?
Setup a follow-up intent, with phrases My name is Yuri Alves, I am Yuri
Alves etc
Make an entity name_entity for recognizing the first name and last name
Mark the entity as required
Give prompt What is your name?
In the response print Hello, $name_entity
Hope it helps.

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