Dialogflow v2 error “MalformedResponse 'final_response' must be set”

谁说胖子不能爱 提交于 2019-12-13 16:06:48

问题


I am getting this error only when using the simulator/google assistant. When I use the Slack integration or test within DialogFlow then it works perfectly.

I checked this question about settings in DialogFlow, but that wasn't my issue. I checked this question but because I use python in my webhook, I can't be sure whether that would solve it for me or not.

I am doing the following:

First, the user invokes any one of my intents which are connected through a webhook to my python code. Call this intent1.

Second, I check to see what the response (response1) would be for intent1 in my code.

Third, I send response1 to another intent intent2 via a followup-event event2.

The reason why I'm doing this just for interest is that I'm allowing multiple types of conversation flows. The first being FAQs and the second being a directed conversation.

The JSON I'm sending back is:

"followupEventInput":{  
              "name":"EventName",
              "parameters":{
                  "speech": str(speech)
                  }
              }

EventName is event2.

speech is response1

I also tried adding this to the JSON, but it didn't change anything:

,"payload": {"google":{"expectUserResponse": False}}

The Debug from the simulator shows:

{
  "response": "",
  "expectUserResponse": false,
  "conversationToken": "GidzaW11bG...",
  "audioResponse": "//NExAASWK...",
  "debugInfo": {
    "assistantToAgentDebug": {
      "curlCommand": "curl -v 'https://api.api.ai/api/integrations/google?token=2b0fcc112a9b40c48f7a7182a29f6b2f' -H 'Content-Type: application/json;charset=UTF-8' -H 'Google-Actions-API-Version: 2' -H 'Authorization: eyJhbGciOiJSUzI1NiIsImtpZCI6IjQxMjlkYjJlYTE4NjBkMmU4NzFlZTQ4NTA2Mjg3ZmIwNWIwNGNhM2YifQ.eyJhdWQiOiJkbmFmaXQtZmFxIiwiZXhwIjoxNTMwODU5MzIzLCJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJqdGkiOiJiNDcwZjdhODYyYWJiMzI0NjRjNGY5MmU4MTQ1ZWU5NTFlYTA1MWY5IiwiaWF0IjoxNTMwODU5MjAzLCJuYmYiOjE1MzA4NTg5MDN9.XMAmItiH9SEo1I24T5xEPvSfP7dPX21AYHvVqZZReayNoR396ZQ1JdHZiY9rwGfp49qSwn2ea9EDkNVCQ-PK8NIKdTdxG-L0HuhY7r8nEMfzO4PjJKU6bI-Ry1OwL3A90WGK0l8rwJpByHSfA1gTsS7PU983yyR51PCJFkVnd2KQfX1ZKPIqpcEzKkCvexh9mwOx8cH6iVYuBzmHctH1FRLqhzzRb9zcx3Qq2mDFB8cVbl8SluXLyV4hBeKSeFe-HnkWEzqE3zvgIbAZha2rAOMb2xx1ta_M86hmwET4woAB-hBlR77cyNZV49Y5GmFrF5DozvQWEw1GNoRxcZCLhA'  -A 'Mozilla/5.0 (compatible; Google-Cloud-Functions/2.1; +http://www.google.com/bot.html)' -X POST -d '{\"user\":{\"userId\":\"ABwppHEpW9IVOkzk8egeV0A0NHO5Ug4wqLj3ney3hdwx_iPW4cMeayYws8m-fzoFiYksk7JsnDmi-g\",\"locale\":\"en-US\",\"lastSeen\":\"2018-07-05T15:54:50Z\"},\"conversation\":{\"conversationId\":\"1530859188209\",\"type\":\"ACTIVE\",\"conversationToken\":\"[]\"},\"inputs\":[{\"intent\":\"actions.intent.TEXT\",\"rawInputs\":[{\"inputType\":\"KEYBOARD\",\"query\":\"what are the best recipes for oranges\"}],\"arguments\":[{\"name\":\"text\",\"rawText\":\"what are the best recipes for oranges\",\"textValue\":\"what are the best recipes for oranges\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"},{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]}],\"requestType\":\"SIMULATOR\"}'",
      "assistantToAgentJson": "{\"user\":{\"userId\":\"ABwppHEpW9IVOkzk8egeV0A0NHO5Ug4wqLj3ney3hdwx_iPW4cMeayYws8m-fzoFiYksk7JsnDmi-g\",\"locale\":\"en-US\",\"lastSeen\":\"2018-07-05T15:54:50Z\"},\"conversation\":{\"conversationId\":\"1530859188209\",\"type\":\"ACTIVE\",\"conversationToken\":\"[]\"},\"inputs\":[{\"intent\":\"actions.intent.TEXT\",\"rawInputs\":[{\"inputType\":\"KEYBOARD\",\"query\":\"what are the best recipes for oranges\"}],\"arguments\":[{\"name\":\"text\",\"rawText\":\"what are the best recipes for oranges\",\"textValue\":\"what are the best recipes for oranges\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"},{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]}],\"requestType\":\"SIMULATOR\"}"
    },
    "agentToAssistantDebug": {
      "agentToAssistantJson": "{\n  \"responseMetadata\": {\n    \"status\": {\n      \"code\": 10,\n      \"message\": \"Failed to parse Dialogflow response into AppResponse because of empty speech response\",\n      \"details\": [{\n        \"@type\": \"type.googleapis.com/google.protobuf.Value\",\n        \"value\": \"{\\\"id\\\":\\\"63a2647e-43fc-4c36-9067-5c48b51626bb\\\",\\\"timestamp\\\":\\\"2018-07-06T06:40:04.014Z\\\",\\\"lang\\\":\\\"en-us\\\",\\\"result\\\":{},\\\"status\\\":{\\\"code\\\":200,\\\"errorType\\\":\\\"success\\\"},\\\"sessionId\\\":\\\"1530859188209\\\"}\"\n      }]\n    }\n  }\n}"
    },
    "sharedDebugInfoList": [
      {
        "name": "ResponseValidation",
        "debugInfo": "",
        "subDebugEntryList": [
          {
            "name": "MalformedResponse",
            "debugInfo": "'final_response' must be set.",
            "subDebugEntryList": []
          }
        ]
      }
    ]
  },
  "visualResponse": {
    "visualElementsList": [],
    "suggestionsList": [],
    "agentLogoUrl": ""
  },
  "clientError": 0,
  "is3pResponse": 1
}

回答1:


The value of the agentToAssistantJson field includes the message "Failed to parse Dialogflow response into AppResponse because of empty speech response". As it suggests, whatever you're sending in your response is missing speech information.

You don't specify what Event2 is doing, what it is sending back, or what it is doing with the parameter (if anything), but the likely issue is that it isn't sending back anything. Just including the speech as a parameter doesn't do anything - parameters are just information, not replies.

While there are some uses for followup events, most of the time they aren't what you really want. If you want to reply with a message from the fulfillment - just reply with the message.



来源:https://stackoverflow.com/questions/51204486/dialogflow-v2-error-malformedresponse-final-response-must-be-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!