Dialogflow v2 错误“必须设置 MalformedResponse 'final_response'”

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

只有在使用 simulator/google 助手时才会出现此错误。当我在 DialogFlow 中使用 Slack 集成或测试时,它工作得很好。

我检查了这个 about settings in DialogFlow, but that wasn't my issue. I checked this question 但因为我在我的 webhook 中使用了 python,所以我不确定这是否会为我解决问题,或者没有。

我正在做以下事情:

首先,用户调用我的任何一个意图,这些意图通过 Webhook 连接到我的 python 代码。调用此 intent1.

其次,我检查代码中 intent1 的响应 (response1)。

第三,我通过后续事件 event2.

response1 发送到另一个意图 intent2

我之所以这样做只是为了兴趣,是因为我允许多种类型的对话流。第一个是常见问题解答,第二个是定向对话。

我发回的 JSON 是:

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

EventNameevent2.

speechresponse1

我也试过将它添加到 JSON,但它没有改变任何东西:

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

模拟器的调试显示:

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

agentToAssistantJson 字段的值包含消息 "Failed to parse Dialogflow response into AppResponse because of empty speech response"。正如它所暗示的,无论您在回复中发送什么,都缺少语音信息。

您没有具体说明 Event2 在做什么、它发回了什么或者它对参数做了什么(如果有的话),但可能的问题是它没有发回任何东西。仅将语音作为参数包含在内没有任何作用 - 参数只是信息,而不是回复。

虽然后续事件有一些用途,但大多数时候它们并不是您真正想要的。如果您想回复来自 fulfillment 的消息 - 只需回复消息即可。