Invalid response from webhook: Failed to translate JSON to ExecuteHttpResponse

1.2k views Asked by At

I have a webhook from my google assistant new actions builder platform. Webhook code is written in the dotnet vs2019. I have followed the webhook request and response format and sample jsons provided in the below links.

https://developers.google.com/assistant/conversational/reference/rest/v1/TopLevel/fulfill#User

https://developers.google.com/assistant/conversational/webhooks#request-json_1

But when I test assistant action, it is failing. Below is request and response json from logs in the google assistant test simulator.Error message just says"Invalid response from webhook: Failed to translate JSON to ExecuteHttpResponse." I don't know why it is not valid. Can someone help me resolving this.

{
  "requestJson": {
    "handler": {
      "name": "agentcube"
    },
    "intent": {
      "name": "",
      "params": {
        "phone": {
          "original": "1234562869",
          "resolved": 1234562869
        }
      },
      "query": "1234562869"
    },
    "scene": {
      "name": "Start",
      "slotFillingStatus": "FINAL",
      "slots": {
        "Zip": {
          "mode": "REQUIRED",
          "status": "SLOT_UNSPECIFIED",
          "updated": false,
          "value": 37122
        },
        "Phone": {
          "mode": "REQUIRED",
          "status": "SLOT_UNSPECIFIED",
          "updated": true,
          "value": 1234562869
        },
        "FName": {
          "mode": "REQUIRED",
          "status": "SLOT_UNSPECIFIED",
          "updated": false,
          "value": "john doe"
        }
      },
      "next": {
        "name": "actions.scene.END_CONVERSATION"
      }
    },
    "session": {
      "id": "ABwppHFkFuGBF-UawPmIkxWpkfM1Hb5An7h8KnjR302zukmBoKA1NqDp7DfePGzYsyxT5oy--wg5Jkjj",
      "params": {
        "Phone": 1234562869,
        "FName": "john doe",
        "Zip": 37122
      },
      "typeOverrides": [],
      "languageCode": ""
    },
    "user": {
      "locale": "en-US",
      "params": {},
      "accountLinkingStatus": "NOT_LINKED",
      "verificationStatus": "VERIFIED",
      "packageEntitlements": [],
      "gaiamint": "",
      "permissions": [],
      "lastSeenTime": "2021-01-28T19:21:28Z"
    },
    "home": {
      "params": {}
    },
    "device": {
      "capabilities": [
        "SPEECH",
        "RICH_RESPONSE",
        "LONG_FORM_AUDIO"
      ]
    }
  }
}

  

Invalid response from webhook: Failed to translate JSON to ExecuteHttpResponse..

{
  "responseJson": {
    "Session": {
      "Id": "ABwppHFkFuGBF-UawPmIkxWpkfM1Hb5An7h8KnjR302zukmBoKA1NqDp7DfePGzYsyxT5oy--wg5Jkjj",
      "Params": {
        "Phone": 1234562869,
        "Zip": 37122,
        "FName": "john doe"
      }
    },
    "Prompt": {
      "Override": false,
      "FirstSimple": {
        "Speech": "My webhook response",
        "Text": "My response from webhook"
      }
    },
    "Scene": {
      "Name": "Start",
      "SlotFillingStatus": "FINAL",
      "Slots": {
        "Phone": {
          "Mode": "REQUIRED",
          "Status": "SLOT_UNSPECIFIED",
          "Updated": true,
          "value": 1234562869
        },
        "FName": {
          "Mode": "REQUIRED",
          "Status": "SLOT_UNSPECIFIED",
          "Updated": false,
          "value": "john doe"
        },
        "Zip": {
          "Mode": "REQUIRED",
          "Status": "SLOT_UNSPECIFIED",
          "Updated": false,
          "value": 37122
        }
      },
      "Next": {
        "Name": "actions.scene.END_CONVERSATION"
      }
    }
  }
}
1

There are 1 answers

0
FastGTR On

Make sure the response that you code is returning is json by checking with a linter, which this seems to checks (i.e. everything inside the ResponseJson {} Please see my response to a similar issue at https://stackoverflow.com/a/66512370/10537202 to use the webhook playground.