Identifying numbers correctly - dialogflow-es

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"
}

Related

Expecting two different responses, accepting one?

I have a similar problem to this one: Two Different Response in Retrofit
However, both things that I've tried have not worked. I'm new to this and can't seem to find any other sources that are of use. I'm so so sorry if this is a dumb question, but I've been struggling with this for a week now.
Important information: I am coding in Jetpack Compose and using Retrofit2. To test data calls, I am using postman.
Success Response: [ Info changed for identification purposes, it responds with actual user data ]
{
"data": {
"id": 0,
"name": "First Last",
"first_name": "First",
"last_name": "Last",
"email": "name#yup",
"is_verified": true,
"created_at": 1666202587,
"meta": {
"image": "avatarImage",
"username": "",
"rng": " ",
"date_of_birth": null,
"city": null
}
},
"token": "correct token"
}
Error Response:
Error response
Data class:
Data class
In my first attempt, I made two data classes and split up the different responses. However, that just led to them both being null regardless of what I input. Once I moved them to once data class, it allows the user to sign in just fine, but the error is never caught and instead just crashes my app.

Is it possible to replace a part of value from captured correlation in Loadrunner?

I am correlating json response, but from the captured json I need to replace a value with some different text.
For example - captured response is as below and saved to "corr_json"variable:
{
"data": [{
"type": "articles",
"id": "1",
"attributes": {
"title": JSON:API paints my bikeshed!,
"body": "The shortest article. Ever.",
"created": "2015-05-22T14:56:29.000Z",
"updated": "2015-05-22T14:56:28.000Z"
},
"relationships": {
"author": {
"data": {"id": "42", "type": "people"}
}
}
from this I need to replace string
API paints my bikeshed
with text Performance Testing and pass to next request, so the json to be pass as below:
{
"data": [{
"type": "articles",
"id": "1",
"attributes": {
"title": "Performance Testing",
"body": "The shortest article. Ever.",
"created": "2015-05-22T14:56:29.000Z",
"updated": "2015-05-22T14:56:28.000Z"
},
"relationships": {
"author": {
"data": {"id": "42", "type": "people"}
}
}
Is there a way to do this in Loadrunner?
Check lr_json_replace api provided by LoadRunner.
Depending upon your protocol in use, the language of LoadRunner is either C, C#, C++, VB, or JavaScript. Use the sting processing capabilities of your language, combined with your programming skills to reformat the text in question to include your tag.
Hint, you might consider two correlations on the returned data, one which begins with the first curly brace and ends with '"title":' with the second beginning with '"title":' and ending with the '\t\t}\r\t}' (if I am reading the text right) structure. Then you could simply sprintf() in C to pack a few strings (corr1+ your tag+corr2+ end structure) together to hit your mark.

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.

How to take Multi-value from one sentence using API.AI?

I'm new to Api.ai , i read the doc. but i didn't understand how Api.ai works better with many parameters.
I'll try to explain by an example :
I have a Management software which manages the members/actions/projects , where i can get the actions of any member at any project using the normal interface.
let's replace this with a smart bot where the chat will run as i expected below,
USER : i want to see my actions for ANY PROJECT NAME HERE
bot : your action is XXXXXX.
OR
USER: give me all the members of the project ANY PROJECT NAME
Bot: Members are "1-2-3-4-5-...."
i think you got what i mean , if you need more i can explain more.How can i let Api.ai understands this ?
For API.ai to 'remember' values (ie store and retrieve information such as the names of projects, actions and team members) you will need to connect API.ai to a webhook/database of your own, there isn't anyway for API.ai to do this on its own.
Once you connect API.ai to a custom webhook/database you can use the variables that API.ai will parse for you to run your query. You simply need to build the intents corresponding to the search and parameters involved
Here's how the process would flow:
User asks "I want to see my actions for [ANY PROJECT NAME HERE]"
API ai logic recognizes this as the intent 'search-action' for $project_name, you having set this up in API.ai like this
Your custom webhook receives JSON response from API.ai that in this case would look like this:
{
"id": "REDACTED",
"timestamp": "2017-04-19T03:18:18.028Z",
"lang": "en",
"result": {
"source": "agent",
"resolvedQuery": "I want to see my actions for project Unicorn",
"action": "search-action",
"actionIncomplete": false,
"parameters": {
"project_name": "project Unicorn"
},
"contexts": [],
"metadata": {
"intentId": "REDACTED",
"webhookUsed": "false",
"webhookForSlotFillingUsed": "false",
"intentName": "Search - Actions"
},
"fulfillment": {
"speech": "",
"messages": [
{
"type": 0,
"speech": ""
}
]
},
"score": 1
},
"status": {
"code": 200,
"errorType": "success"
},
"sessionId": "REDACTED"
}
So, your webhook has logic that recognizes when result.action is 'search-action' is should run a database search for actions in project result.parameters.project_name
Your webhook fulfills the API.ai request, or alternatively, sends message to message platform directly (ie Facebook messenger)

Resources