Dialogflow is making a wrong match - dialogflow-es

I need help on how the Dialogflow algorithm prioritizes entities.
For example:
The entity:
[
{
"value": "1",
"synonyms": [
"AG101PL"
]
When the user input is: AG101PL, the value which matches is: 1, and the intent is set to: AG101PL intent.
But:
When the user input is: S2_AG101PL, the value which matches is still: 1
The intent is rightly set to: S2_AG101PL
The entity:
[
{
"value": "2",
"synonyms": [
"S2_AG101PL" ]
So the problem is that Dialogflow regonizes S2_AG101PL as AG101PL, and thus gives the wrong output when using $entity in the intent output
Does somebody have a solution for my problem?
It's for a Automatic dialog which gives product information about a speficied product (eg. AG101PL).
Already tried putting more synonyms, hoping that dialogflow prioritizes both 2 synonym matches in the same sentence or even putting S2_ and AG101PL in different entities. But still, no luck.

Related

Dialogflow Fulfillment URLnot sending any data

I am building a bot for google assistant. I have enabled fulfillment section for some intents. Dialog flow sends the request to the fulfillment url. The url is executed and a hard coded response is returned. I can see the response in the assistant simulator. Everything works fine except one thing. The request is empty.I can't access fields that are supposed to be present in the request.
I have accessed the same url using post request from a python code and it displays the parameters. So, there are no issues in the code. I think I am missing some configuration option.
I was expecting the post body in the following format:
POST body:
{
"responseId": "ea3d77e8-ae27-41a4-9e1d-174bd461b68c",
"session": "projects/your-agents-project-id/agent/sessions/88d13aa8-2999-4f71-b233-39cbf3a824a0",
"queryResult": {
"queryText": "user's original query to your agent",
"parameters": {
"param": "param value"
},
"allRequiredParamsPresent": true,
"fulfillmentText": "Text defined in Dialogflow's console for the intent that was matched",
"fulfillmentMessages": [
{
"text": {
"text": [
"Text defined in Dialogflow's console for the intent that was matched"
]
}
}
],
"outputContexts": [
{
"name": "projects/your-agents-project-id/agent/sessions/88d13aa8-2999-4f71-b233-39cbf3a824a0/contexts/generic",
"lifespanCount": 5,
"parameters": {
"param": "param value"
}
}
],
"intent": {
"name": "projects/your-agents-project-id/agent/intents/29bcd7f8-f717-4261-a8fd-2d3e451b8af8",
"displayName": "Matched Intent Name"
},
"intentDetectionConfidence": 1,
"diagnosticInfo": {},
"languageCode": "en"
},
"originalDetectIntentRequest": {}
}
But when I print the post data using print(request.POST), the actual post request shown is
One more thing: Does dialog flow append the action at the end of the fulfillment url? If so, I will have to handle the logic separately. I have done it without considering the action name. But a lot of my stuff is hacked, so I just want to be sure.
On another note, is dialogflow good enough? It has worked fine on a few examples similar to what it was trained on. How many training samples does it need to work properly? What is the underlying algorithm used in dialogflow? Or should I use the fulfillment url and handle everything on my own? I am inclined towards the later. I do not have too much faith in the existing chatbots.
Any help is appreciated.
If the Fallback Intent is the one being triggered, then you wouldn't get any parameters since this means that nothing else matched.
Got it. Used request.body. This solves the problem. Then parsed it using json.loads and accessed the parameters.

Dialogflow Not able to use Parameter in response

I am trying to use Dialogflow, and following their guide building-your-first-agent to create an intent with response
However, if I use the parameter inside the response, it will return 'not available' from default response. Does anyone know why it is happening?
From the picture, it will response the correct sentence without parameter. the response is not available when using parameter.
Diagnostic info
without parameter
{
"id": "aa316e0a-7f41-46cb-a03c-03c13d80ae6b",
"timestamp": "2018-05-16T18:31:11.858Z",
"lang": "en",
"result": {
"source": "agent",
"resolvedQuery": "turn on asdkasjd",
"action": "",
"actionIncomplete": false,
"parameters": {
"cameraName": ""
},
"contexts": [],
"metadata": {
"intentId": "41b046bc-65ea-425b-8a33-9e37c44dddf4",
"webhookUsed": "false",
"webhookForSlotFillingUsed": "false",
"intentName": "opencamera"
},
"fulfillment": {
"speech": "Sorry I don't know",
"messages": [
{
"type": 0,
"speech": "OK. I will try to turn on"
}
]
},
"score": 0.9300000071525574
},
"status": {
"code": 200,
"errorType": "success"
},
"sessionId": "e488d71a-a21e-4cf0-bfcb-13b4a36fd811"
}
The problem is that you're using the #sys:given-name parameter in an attempt to match "camera" or "camera two", but neither of these are a "given name", which is meant to match the name given to a person (as opposed to their family name), not the name given to a device.
In these cases, it is using some rough matching and determining that "turn on" matches enough of the sample phrase to match the Intent, but that there is no value that matches the name part of it. Since that parameter isn't required, the Intent matches without a value for the parameter.
There are a few things you can do to remedy this, depending on your exact needs:
You may wish to mark the parameter as required. (This doesn't solve the name issue, but will make sure it is either matched or the user is prompted for the value.)
You can use the #sys:any entity type. This should match anything the user includes for the parameter.
If you have some defined names, you can define your own entity type.
First, I think you have not added any phrases in 'Training Phrases' section above 'Action and Parameters' section. Please add those to train your agent to detect 'cameraName' parameter from phrases. Secondly, if you see your json, result->parameters->cameraName is empty. And if the parameter is empty, it cannot respond with a response that requires the parameter 'cameraName'. Try adding a third response under responses with parameters that does not uses parameter and see the result, it will return the third response and when it will detect the parameter, it will start showing response with the parameter.

What are the longform field names for the select statements in Microsoft Academic Graph Search?

I'm trying to use the JSON search endpoint for the MS Academic Knowledge Graph and finding it difficult to work out what the legal "Select" fields are.
For example, I am interested in the author's affiliation
POST /academic/v1.0/graph/search?mode=json
{
"path":"/v0/",
"v0" : {
"match": {
"Name": "stephen hawking",
},
"type": "Author",
"select": [ "DisplayAuthorName", "AffiliationName" ]
}
}
There is no obvious way of working out these field names. The documentation gives the shortform entity names like "DAuN" which do not seem to work in the graph api.
Where can I get a comprehensive list of legal knowledge graph "select" fields?

Identifying numbers correctly

I have an intent where I might say 'Transfer 4 to Bob' and it identifies this as 'Transfer for to Bob'
Also I might say 'Transfer 10 to Bob and it identifies this as 'Transfer 102 Bob' treating to word to as 2 on the end of the previous number.
What is the best way to get API.AI to recognise these parts correctly so 4 is not for and to is not 2?
You mentioned that you're using the Actions on Google platform. This means that speech recognition - the process of translating what the user says into text - is happening before the data gets to API.AI.
The problem you're experiencing is that Actions on Google is misrecognizing some numbers as words, e.g. four becomes for.
Because this happens before - and separately from - API.AI, you won't be able to fix the misrecognition.
Below, I'll explain how you can work around this issue in API.AI. However, it's also worth thinking about how you could make your conversation design as robust as possible so that issues like this are less likely to cause problems.
One way you could increase robustness would be to mark the number as a required parameter in API.AI so the user is prompted if it isn't detected due to a recognition error. In that case, the dialog would go like this:
User: Give me four lattes.
App: Sure, four lattes coming up.
User: Give me for lattes.
App: How many do you want?
User: Four.
App: Sure, four lattes coming up.
Regardless, here's a workaround you can use to help recover from misrecognition:
In your intent, provide examples of these commonly misrecognized values. Highlight and mark them as numbers.
Test out your intent out in the console and you'll see that "for" is now matched as a "number" entity with value "for".
In your fulfillment webhook, check the parameter for this value and convert it to the appropriate number using a dictionary. Here's the JSON for the above query:
{
"id": "994c4e39-be49-4eae-94b0-077700ef87a3",
"timestamp": "2017-08-03T19:50:26.314Z",
"lang": "en",
"result": {
"source": "agent",
"resolvedQuery": "Get me for lattes",
"action": "",
"actionIncomplete": false,
"parameters": {
"drink": "lattes",
"number": "for" // NOTE: Convert this to "4" in your webhook
},
"contexts": [],
"metadata": {
"intentId": "0e1b0e72-78ba-4c61-a4fd-a73788034de1",
"webhookUsed": "false",
"webhookForSlotFillingUsed": "false",
"intentName": "get drink"
},
"fulfillment": {
"speech": "",
"messages": [
{
"type": 0,
"speech": ""
}
]
},
"score": 1
},
"status": {
"code": 200,
"errorType": "success"
},
"sessionId": "8b0891c1-50c8-43c6-99c4-8f77261acf86"
}

Alexa Custom Slot picking up additional words

I'm trying to create a custom slot for a UK postcode (e.g. CB1 1PT). I managed to get this working around October time, however, I've come back to the project and it looks like Amazon have updated a number of things.
Here is my Intent Schema:
{
"intents": [
{
"intent": "GetOutages",
"slots": [
{
"name": "postcode",
"type": "LIST_OF_POSTCODES"
}
]
},
{
"intent": "GetCoverage",
"slots": [
{
"name": "postcode",
"type": "LIST_OF_POSTCODES"
}
]
},
{
"intent": "AMAZON.StopIntent",
"slots": []
},
{
"intent": "AMAZON.CancelIntent",
"slots": []
}
]
}
The Custom Slot type:
LIST_OF_POSTCODES S L six six D Y | C B one one P T | R G five four W L | G U one five one P B
A few sample utterances:
GetOutages outage info for {postcode}
GetOutages fault info for {postcode}
GetOutages information for {postcode}
GetOutages outage information for {postcode}
GetOutages fault information for {postcode}
The problem is, when I try to retrieve the value from the slot, it appears to be picking up the full sentence:
{
name:'GetOutages',
slots:{
postcode:{
name:'postcode',
value:'information for r g 54 w l'
}
}
}
Does anyone have any advice?
Not really a proper answer, but some thoughts...
You provide sample utterences, but in the rest of your utterances are there any that are so short/generic that they could get inadvertently matched, and then most of the user's actual utterance getting put in postcode?
Also, I gotta wonder what your list of words is for that slot? Since it is limited to 65K items you can't supply all the postcodes, so what shortcut are you taking?
Finally, what you really need, of course, is a built-in slot type for UK postcode like they have for US zipcode. Here is the ASK feature request for it, and note the link to the suggested stop gap:
https://forums.developer.amazon.com/content/idea/41072/built-in-slot-type-for-uk-postcodes.html
correction: there are various address and city built-ins, but they don't support US zipcode either, so I guess people must be using AMAZON.NUMBER.

Resources