I am querying elastic search using status field and range but getting an error:
"type": "parsing_exception","reason": "[status] query malformed, no
start_object after query name"
Query looks as below:
{
"_source": {
"includes": []
},
"query": {
"bool": {
"must": [
{
"status": "IN_PROGRESS"
},
{
"range": {
"requestDate": {
"gte": "2018-10-01T08:00:00.000Z",
}
}
}
]
}
},
"sort": {
"requestDate": {
"order": "desc"
}
}
}
The error is that you haven't specified the query type - term or match - against status field. So if status is a text datatype, you should perform a match query:
{
"_source": {
"includes": []
},
"query": {
"bool": {
"must": [
{
"match":{ "status": "IN_PROGRESS"
}},
{
"range": {
"requestDate": {
"gte": "2018-10-01T08:00:00.000Z",
}
}
}
]
}
},
"sort": {
"requestDate": {
"order": "desc"
}
}
}
I am trying to query my elastic search server in python, If I hard coded the url and query string like below in my python (search()) script working fine no issues. If I want to store those url and query in a separate xml file (property file). I'm not getting the results instead I got the below error:
text '{"error":{"root_cause":[{"type":"parsing_exception","reason":"Expected [START_OBJECT] but found [VALUE_STRING]","line":1,"col":1}],"type":"parsing_exception","reason":"Expected [START_OBJECT] but found [VALUE_STRING]","line":1,"col":1},"status":400}' str
Here is my code I am using
def search():
url="http://0.0.0.0/logstash-pse*/_search/"
query={ "size": 0, "aggs": { "2": { "date_histogram": { "field": "#timestamp", "interval": "30m", "time_zone": "America/Chicago", "min_doc_count": 1 }, "aggs": { "3": { "terms": { "field": "queryname.keyword", "size": 100, "order": { "1.90": "desc" } }, "aggs": { "1": { "percentiles": { "field": "queryResponseTime", "percents": [ 90 ], "keyed": "false" } } } } } } }, "query": { "bool": { "must": [ { "query_string": { "query": "path: \"/store_locator/\"", "analyze_wildcard": "true" } }, { "query_string": { "analyze_wildcard": "true", "query": "*" } }, { "range": { "#timestamp": { "gte": 1527181463371, "lte": 1527267863371, "format": "epoch_millis" } } } ], "must_not": [] } }, "highlight": { "pre_tags": [ "#kibana-highlighted-field#" ], "post_tags": [ "#/kibana-highlighted-field#" ], "fields": { "*": { "highlight_query": { "bool": { "must": [ { "query_string": { "query": "path: \"/store_locator/\"", "analyze_wildcard": "true", "all_fields": "true" } }, { "query_string": { "analyze_wildcard": "true", "query": "*", "all_fields": "true" } }, { "range": { "#timestamp": { "gte": 1527181463371, "lte": 1527267863371, "format": "epoch_millis" } } } ], "must_not": [] } } } }, "fragment_size": 2147483647 }, "_source": { "excludes": [] }, "version": "true"}
response = requests.post(url, auth=(user, password), verify=False,json=query)
XML property file I am using like the below:
<custom>
<url>the above url goes here</url>
<query> above query </query>
</custom>
Any idea what I am missing?, Much appreciated
Able to figure it out with few exercise on my own. In case if someone is looking for:
I just used the below
response = requests.post(url, auth=(user, password), verify=False,json=json.loads(query))
I've been struggling with getting an assistant app to respond correctly.
This app is written with Google Actions SDK (there are no other components such as Dialogflow or Converse.ai).
The action package for the app looks something like this:
{
"actions":[
{
"description": "Default Welcome Intent",
"name": "MAIN",
"fulfillment": {
"conversationName": "ACTION_INTENT_MAIN"
},
"intent": {
"name": "actions.intent.MAIN",
"trigger": {
"queryPatterns": [
"talk to gactions integration"
]
}
}
}
],
"conversations":{
"ACTION_INTENT_MAIN": {
"name": "ACTION_INTENT_MAIN",
"url": "https://my.custom.end/point"
}
},
"locate":"en"
}
This is the JSON request that I recieve on https://my.custom.end/pont:
{
"user": {
"userId": "<a-user-id-sent-by-GOOG>",
"locale": "en-US",
"lastSeen": "2018-01-31T09:33:07Z"
},
"conversation": {
"conversationId": "1517393479793",
"type": "NEW"
},
"inputs": [
{
"intent": "actions.intent.MAIN",
"rawInputs": [
{
"inputType": "KEYBOARD",
"query": "Talk to Gactions Integration"
}
]
}
],
"surface": {
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.MEDIA_RESPONSE_AUDIO"
},
{
"name": "actions.capability.WEB_BROWSER"
}
]
},
"isInSandbox": true,
"availableSurfaces": [
{
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
}
]
}
]
}
An on the simulator, I end up getting this response: API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: ": Cannot find field.".
I can confirm that the incoming request has the google-actions-api-version set to 2.
This is the sharedDebugInfo section from the Actions on Google simulator:
[
{
"name": "ResponseValidation",
"subDebugEntry": [
{
"debugInfo": "API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: \": Cannot find field.\".",
"name": "UnparseableJsonResponse"
}
]
}
]
The oh-so-informative error message lacks the name of the field that cannot be found.
And this is when I'm doing everything described here
UPDATE - 01 February, 2018, 11:52 AM
These are the full contents of the debug tab:
{
"audioResponse": "//NExAAQaE...",
"conversationToken": "GidzaW11bG...",
"debugInfo": {
"agentToAssistantDebug": {
"agentToAssistantJson": "{\"conversationToken\":\"{\\\"state\\\":null,\\\"data\\\":{}}\",\"expectUserResponse\":true,\"expectedInputs\":[{\"inputPrompt\":{\"noInputPrompts\":[],\"richInitialPrompt\":{\"items\":[{\"simpleResponse\":{\"textToSpeech\":\"You're now talking to GActions Integration\",\"displayText\":\"You're now talking to GActions Integration\"}},{\"basicCard\":{\"buttons\":[{\"title\":\"Some Reddit to chill\",\"openUrlAction\":{\"url\":\"https://www.reddit.com\"}}],\"formattedText\":\"Here's some simp-wave to relax and chill out to\",\"image\":{\"url\":\"http://tracks.arte.tv/sites/default/files/styles/jscrop_1007x566/public/c_simpsons_2.jpg?itok=INzKpsvK\",\"accessibilityText\":\"A World of Simpsonwave\"},\"title\":\"A World of Simpsonwave\",\"imageDisplayOptions\":\"CROPPED\"}}],\"suggestions\":[]}},\"possibleIntents\":[{\"intent\":\"actions.intent.TEXT\"}]}],\"resetUserStorage\":false,\"userStorage\":\"{}\",\"finalResponse\":null,\"isInSandbox\":true,\"customPushMessage\":null,\"speech\":\"You're now talking to GActions Integration. \",\"displayText\":\"You're now talking to GActions Integration. \"}"
},
"assistantToAgentDebug": {
"assistantToAgentJson": "{\"user\":{\"userId\":\"ABwppHHHw9N9TYh-scJ5GhZtmpfFcQU2xbQBAgW1qhdllI45fimQ5QKFEVRfs2iMm6uCDJIQMApo1UZLmmnif8wqlNARnsVH744\",\"locale\":\"en-US\",\"lastSeen\":\"2018-02-01T06:04:59Z\"},\"conversation\":{\"conversationId\":\"1517465629416\",\"type\":\"NEW\"},\"inputs\":[{\"intent\":\"actions.intent.MAIN\",\"rawInputs\":[{\"inputType\":\"VOICE\",\"query\":\"Talk to Gactions Integration\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"}]}]}",
"curlCommand": "curl -v https://firedev.arrowai.com/integrations/goog-actions/messages/59f6b4bf8d16126f008b456a/5a619bf72c971189008b4569 -H 'Content-Type: application/json;charset=UTF-8' -H 'Google-Actions-API-Version: 2' -H 'Authorization: eyJhbGciOiJSUzI1NiIsImtpZCI6IjI2YzAxOGIyMzNmZTJlZWY0N2ZlZGJiZGQ5Mzk4MTcwZmM5YjI5ZDgifQ.eyJhdWQiOiJnYWN0aW9ucy1hcnJvd2FpLWludGVncmF0ZSIsImF6cCI6IjQ2NDA5MDk1NDc2Ny0xOWl2bnUxdjFwYXFpdWdodDJqYXJwcTJwaGtmNGRyMS5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsImV4cCI6MTUxNzQ2NTc0OSwiaXNzIjoiaHR0cHM6Ly9hY2NvdW50cy5nb29nbGUuY29tIiwianRpIjoiZTgxNzlmN2FkZGYwYWZmYjYwNzk0MDg5MzIyN2E0MWU1NDZkZWMyOCIsImlhdCI6MTUxNzQ2NTYyOSwibmJmIjoxNTE3NDY1MzI5fQ.rmUxBhIirV0UnZvTLYYw4AtRQfNDF-3O6CaoXxD2BDZSufgfKFHz7aIUgJzUillBm4zOLFiV6SnXndIoYCG6JK60YK5tHLpqbV-P3C-5U3N05RuY7hpj1Q_B027bgUv-p7QWlg-7DmPkROmN3b3a_FsUeWqTxx5Bu5M551k_CpKvSSBzPMEB2Cw9TzGkiY9avYrISTLLxWl2JE7qKAT6P0zBbE6cdO04CxGddGNmEPkckRICsdSJ5j_wmjy3I-ItAgx3dKoDfFLW6gCI4y5MFsGFJY6cFc2e01nodslf9GlQzAhR_a4aHRRIDl47HT_b9aKpyULV3kiRR41mUkyYZw' -A 'Mozilla/5.0 (compatible; Google-Cloud-Functions/2.1; +http://www.google.com/bot.html)' -X POST -d '{\"user\":{\"userId\":\"ABwppHHHw9N9TYh-scJ5GhZtmpfFcQU2xbQBAgW1qhdllI45fimQ5QKFEVRfs2iMm6uCDJIQMApo1UZLmmnif8wqlNARnsVH744\",\"locale\":\"en-US\",\"lastSeen\":\"2018-02-01T06:04:59Z\"},\"conversation\":{\"conversationId\":\"1517465629416\",\"type\":\"NEW\"},\"inputs\":[{\"intent\":\"actions.intent.MAIN\",\"rawInputs\":[{\"inputType\":\"VOICE\",\"query\":\"Talk to Gactions Integration\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"}]}]}'"
},
"sharedDebugInfo": [
{
"name": "ResponseValidation",
"subDebugEntry": [
{
"debugInfo": "API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: \": Cannot find field.\".",
"name": "UnparseableJsonResponse"
}
]
}
]
},
"response": "Gactions integration isn't responding right now. Try again soon.",
"visualResponse": {
"visualElements": []
}
}
This the agentToAssistantDebug object:
{
"conversationToken": "{\"state\":null,\"data\":{}}",
"expectUserResponse": true,
"expectedInputs": [
{
"inputPrompt": {
"noInputPrompts": [],
"richInitialPrompt": {
"items": [
{
"simpleResponse": {
"textToSpeech": "You're now talking to GActions Integration",
"displayText": "You're now talking to GActions Integration"
}
},
{
"basicCard": {
"buttons": [
{
"title": "Some Reddit to chill",
"openUrlAction": {
"url": "https://www.reddit.com"
}
}
],
"formattedText": "Here's some simp-wave to relax and chill out to",
"image": {
"url": "http://tracks.arte.tv/sites/default/files/styles/jscrop_1007x566/public/c_simpsons_2.jpg?itok=INzKpsvK",
"accessibilityText": "A World of Simpsonwave"
},
"title": "A World of Simpsonwave",
"imageDisplayOptions": "CROPPED"
}
}
],
"suggestions": []
}
},
"possibleIntents": [
{
"intent": "actions.intent.TEXT"
}
]
}
],
"resetUserStorage": false,
"userStorage": "{}",
"finalResponse": null,
"isInSandbox": true,
"customPushMessage": null,
"speech": "You're now talking to GActions Integration. ",
"displayText": "You're now talking to GActions Integration. "
}
Additionally, this is the JSON response that is being generated:
{
"conversationToken": "{\"state\":null,\"data\":{}}",
"expectUserResponse": true,
"expectedInputs": [
{
"inputPrompt": {
"noInputPrompts": [],
"richInitialPrompt": {
"items": [
{
"simpleResponse": {
"textToSpeech": "You're now talking to GActions Integration",
"displayText": "You're now talking to GActions Integration"
}
},
{
"basicCard": {
"buttons": [
{
"title": "Some Reddit to chill",
"openUrlAction": {
"url": "https://www.reddit.com"
}
}
],
"formattedText": "Here's some simp-wave to relax and chill out to",
"image": {
"url": "http://tracks.arte.tv/sites/default/files/styles/jscrop_1007x566/public/c_simpsons_2.jpg?itok=INzKpsvK",
"accessibilityText": "A World of Simpsonwave"
},
"title": "A World of Simpsonwave",
"imageDisplayOptions": "CROPPED"
}
}
],
"suggestions": []
}
},
"possibleIntents": [
{
"intent": "actions.intent.TEXT"
}
]
}
],
"resetUserStorage": false,
"userStorage": "{}",
"finalResponse": null,
"isInSandbox": true,
"customPushMessage": null,
"speech": "You're now talking to GActions Integration. ",
"displayText": "You're now talking to GActions Integration. "
}
The issue seems to be related with your response JSON. As you can see in the documentation regarding the response JSON.
"speech": "You're now talking to GActions Integration. ",
"displayText": "You're now talking to GActions Integration. "
The above are not valid parameters. Instead your response JSON should look like:
{
"conversationToken": "{\"state\":null,\"data\":{}}",
"expectUserResponse": true,
"expectedInputs": [
{
"inputPrompt": {
"noInputPrompts": [],
"richInitialPrompt": {
"items": [
{
"simpleResponse": {
"textToSpeech": "You're now talking to GActions Integration",
"displayText": "You're now talking to GActions Integration"
}
},
{
"basicCard": {
"buttons": [
{
"title": "Some Reddit to chill",
"openUrlAction": {
"url": "https://www.reddit.com"
}
}
],
"formattedText": "Here's some simp-wave to relax and chill out to",
"image": {
"url": "http://tracks.arte.tv/sites/default/files/styles/jscrop_1007x566/public/c_simpsons_2.jpg?itok=INzKpsvK",
"accessibilityText": "A World of Simpsonwave"
},
"title": "A World of Simpsonwave",
"imageDisplayOptions": "CROPPED"
}
}
],
"suggestions": []
}
},
"possibleIntents": [
{
"intent": "actions.intent.TEXT"
}
]
}
],
"resetUserStorage": false,
"userStorage": "{}",
"finalResponse": null,
"isInSandbox": true,
"customPushMessage": null
}
Edit if you use the nodejs sdk check if the response from the google sdk function is correct json and if your server answer with correct json. maybe its change the format etc?
Try it with an action.json style like the first. And the more important question how is your response to the request looking? try that json in the style the last code below creates
{
"locale": "en",
"actions": [
{
"name": "text",
"intent": {
"name": "actions.intent.TEXT",
"trigger": {
"queryPatterns": [
"some text"
]
}
},
"fulfillment": {
"conversationName": "conv name"
}
},
{
"description": "Default Welcome Intent",
"name": "MAIN",
"fulfillment": {
"conversationName": "conv name"
},
"intent": {
"name": "actions.intent.MAIN",
"trigger": {
"queryPatterns": [
"open my test app",
"open hi fish"
]
}
}
}
],
"types": [],
"conversations": {
"conv name": {
"name": "conv name",
"url": "https://yourendpoint.com/something",
"fulfillmentApiVersion": 2,
"in_dialog_intents": [
{
"name": "actions.intent.NO_INPUT"
},
]
}
}
}
this here is a function that create an valid response:
/**
message = string
slots = array
state = object
**/
function answerWithMessage(message,slots,state){
let display = message.replace(/<[^>]*>/g, '');
let voicemessage = message.toLowerCase();
let jsonResponse = {
conversationToken: JSON.stringify(state),
expectUserResponse: true,
expectedInputs: [
{
inputPrompt: {
richInitialPrompt: {
items: [
{
simpleResponse: {
ssml: voicemessage,
displayText: display,
},
}
],
}
},
possibleIntents: [
{
intent: "actions.intent.TEXT"
}
],
speechBiasingHints: slots
}
]
};
return JSON.stringify(jsonResponse,null, 4);
}
And here is a repro with example google actions sdk: https://github.com/haukedau/googleActionsInit but the answer there is not completly correct but it will do the work as well above response message style is better.
Hi I think your issue is just you call an object
"inputPrompt": {
and an array but both are in the same position look in the explanation below.
"noInputPrompts": [],
https://developers.google.com/actions/assistant/helpers#calling_the_helper_1
I hope I could help you.
Best regards
Patrick
My bot wants to send a carousel to Google Assistant through API.AI. My understanding is, I need to enclose it inside data -> google, such as:
{
"data": {
"google": {
"expectUserResponse": true,
"isSsml": false,
"expectedInputs": [
{
"inputPrompt": {
"richInitialPrompt": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Hello World"
}
}
]
}
},
"possibleIntents": [
{
"intent": "actions.intent.OPTION",
"inputValueData": {
"#type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
"carouselSelect": {
"items": [
{
"optionInfo": {"key": "FOO", "synonyms": ["foo"]},
"title": "Foo",
"image": {"url": "http://example.com/", "accessibilityText": "Foo"}
},
{
"optionInfo": {"key": "BAR", "synonyms": ["bar"]},
"title": "Bar",
"image": {"url": "http://example.com/", "accessibilityText": "Bar"}
}
]
}
}
}
]
}
]
}
}
}
But it doesn't work. What is the proper format?
If you are testing this through the Simulator, there should have been a validation error that appeared that would give you at least a little guidance about what is missing. If you didn't even get that, there may be a problem with the other parts besides the data.google object such that api.ai had problems with it.
There are a number of things that, at a glance, could be the problem. You can't just stick a conversation webhook response in the api.ai response. See https://developers.google.com/actions/apiai/webhook#response for the documentation, but here are a few things that I see that could be issues
The expectedInputs property shouldn't be there.
Your data.google.expectedInputs.possibleIntents property should be at data.google.systemIntent
You still need to provide the api.ai fields, such as a basic speech property
The data.google.expectedInputs.inputPrompt.richInitialPrompt would be at data.google.richResponse
Here is some JSON that works for me:
{
"speech": "Hello",
"contextOut": [
{
"name": "_actions_on_google_",
"lifespan": 100,
"parameters": {}
}
],
"data": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Hello"
}
}
],
"suggestions": []
},
"systemIntent": {
"intent": "actions.intent.OPTION",
"data": {
"#type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
"carouselSelect": {
"items": [
{
"title": "Foo",
"image": {
"url": "http://example.com/foo.jpg",
"accessibilityText": "Foo title"
},
"optionInfo": {
"key": "foo-key",
"synonyms": [
"foo-alt-1",
"foo-alt-2"
]
}
},
{
"title": "Bar",
"image": {
"url": "http://example.com/bar.jpg",
"accessibilityText": "Bar title"
},
"optionInfo": {
"key": "bar-key",
"synonyms": [
"bar-alt-1",
"bar-alt-2"
]
}
}
]
}
}
}
}
}
}
My controller looks like this:
def save() {
js {
def color = new Color(params)
color.save()
def result
if (!color.hasErrors())
{
result = [colorname: color.name, colorshde: color.shade]
}
else
{
result = "..."
}
render result as JSON
}
}
The JSON that I desire should look like this:
Successful JSON
{
"meta": {
"status": 200,
"msg": "OK"
},
"response": {
"color": {
"colorname": "Red",
"shade": "light
}
}
}
Unsuccessful response:
{
"meta": {
"status": 400,
"msg": "Something went worn"
},
"response": {
"color": {
}
}
}
Question
How can I modify the controller action to account for both scenarios while returning json?
For successful response:
{
"meta": {
"status": 200,
"msg": "OK"
},
"response": {
"color": {
"colorname": "Red",
"shade": "light
}
}
}
Use:
result = [meta: [status: '200', msg: 'OK'], response:[color:[colorname: color.name, colorshde: color.shade] ] ]
For unsuccessful response:
{
"meta": {
"status": 400,
"msg": "Something went worn"
},
"response": {
"color": {
}
}
}
Use
result = [meta: [status: '400', msg: 'wrong'], response:[color:[] ] ]