API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: \": Cannot find field.\"
Asked Answered
P

6

11

I am getting 'API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: \": Cannot find field.\".' error for simple speech webhook response.

------------ERROR--------------

"debugInfo": {
        "agentToAssistantDebug": {
            "agentToAssistantJson": {
                "message": "Unexpected apiai response format: Empty speech response",
                "apiResponse": {
                    "id": "31f9c31d-3861-4262-8518-bd1f1e895f86",
                    "timestamp": "2017-07-29T22:09:23.971Z",
                    "lang": "en",
                    "result": {},
                    "status": {
                        "code": 200,
                        "errorType": "success"
                    },
                    "sessionId": "1501366152335"
                }
            }
        },
        "sharedDebugInfo": [
            {
                "name": "ResponseValidation",
                "subDebugEntry": [
                    {
                        "name": "UnparseableJsonResponse",
                        "debugInfo": "API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: \": Cannot find field.\"."
                    }
                ]
            }
        ]
    },
    "visualResponse": {}
}

I tried sending following json response as per https://api.ai/docs/reference/agent/query#response document.

------------RESPONSE--------------

{
  "result": {
    "source": "agent",
    "resolvedQuery": "city",
    "action": "tell.facts",
    "actionIncomplete": false,
    "parameters": {
      "facts-category": "city"
    },
    "contexts": [],
    "metadata": {
      "intentId": "873b1895-cdfc-42a4-b61b-5a1703c72a4d",
      "webhookUsed": "true",
      "webhookForSlotFillingUsed": "false",
      "webhookResponseTime": 417,
      "intentName": "tell-facts"
    },
    "fulfillment": {
      "speech": "Amsterdam",
      "messages": [
        {
          "type": 0,
          "speech": "Amsterdam"
        }
      ]
    },
    "score": 1
  }
}

What is it that i'm missing??

Properly answered 29/7, 2017 at 22:58 Comment(1)
Did you manage to resolve this issue? I am running into the same errorBowdlerize
F
2

I had this issue because I had not given any action name. Giving the action name resolved this for me.

Fell answered 21/11, 2017 at 0:53 Comment(0)
R
2

In my case I forget to enable "Use webhook" in Fulfillment and enable "End conversation" in Google Assistant.

Russell answered 16/12, 2017 at 17:25 Comment(0)
A
0

It seems like a bug on an endpoint (heroku or wherever you are hosting your serverside code). Are you sure it's setup correctly and the server is on?

This uses a python dictionary to look up the function and map it to the action name. After that it runs through the associated function which returns a speech response.

@app.route('/google_webhook', methods=['POST'])
def google_webhook():   
    # Get JSON request 
    jsonRequest = request.get_json(silent=True, force=True, cache=False)

    print("Google Request:")
    print(json.dumps(jsonRequest, indent=4))

    # Get result 
    appResult = google_process_request(jsonRequest)
    appResult = json.dumps(appResult, indent=4)

    print("Google Request finished")

    # Make a JSON response 
    jsonResponse = make_response(appResult)
    jsonResponse.headers['Content-Type'] = 'application/json'
    return jsonResponse, jsonRequest


def google_process_request(req):
    action = req.get('result').get('action')  
    session = req.get('sessionId')
    if not action in dict(dispatch_table):
         return {}   

    func = dispatch_table[action]
    speech = func(req)

    print("Google Response:")
    print(speech)
    print("session id is " + session)

    return {
        "speech": speech,
        "displayText": speech,
        "source": "Cloud"
    }
Acetylate answered 31/7, 2017 at 14:0 Comment(2)
I have a inbound REST service on ServiceNow instance. I tested it with other API and its working. xxxxxxxx.service-now.com/api/now/google_assistance_api/…Properly
It may be your serverside code then; I've updated my original response to outline what I do to return the speech response.Acetylate
R
0

A little late, but I recently had the same problem whilst connecting to Google Assistant. After some head scratching I realised that my welcome intent did not have a properly configured voice response. Note that I am not using webhooks at yet. But the error indicates that there is a missing voice response.

In my case I solved it by checking all my intents, and at the bottom of the each intent, writing a text response in the "Default" tab, and then going to the Google Assistant tab, and enabling the "Use response from the DEFAULT tab as the first response." After that, my voice app started working.

Rab answered 23/10, 2017 at 23:49 Comment(0)
L
0

For me it was the action somehow got changed in the Default Welcome Intent. I had an action to go and get the user's name for the welcome message but that had gone. I put it back in and it started working again

Levona answered 1/11, 2017 at 15:43 Comment(0)
J
0

In my case, I got this error after deploying the 'Build your first agent / app' examples for both Dialogflow and AoG. I chose to use the Dialogflow v2 Beta, whereas the 'first app / agent' fulfilment examples currently all use the v1 API. The webhook format has changed significantly for v2.

Until the v2 docs catch up, I'd recommend using the verbose but working Inline Editor fulfilment webhook example as a template, accessible under Fulfilment via the Dialogflow UI, or from https://github.com/dialogflow/fulfillment-webhook-nodejs.

Juliannajulianne answered 22/12, 2017 at 9:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.