Malformed Response 'final_response' must be set

╄→尐↘猪︶ㄣ 提交于 2019-12-14 02:38:40

问题


I'm using DialogFlow's webhook thing and when I send my JSON response as follows:

{
  "fulfillmentText": "This is a text response",
  "source": "example.com",
  "payload": {
    "google": {
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "this is a simple response"
            }
          }
        ]
      }
    }
  }
}

but I get the error MalformedResponse 'final_response' must be set. after the webserver responds.


回答1:


That JSON response is valid for V2 of the Dialogflow webhook fulfillment protocol. Make sure you've done the following:

  1. Make sure you have the V2 API turned on. Click the settings gear in the upper left and click the V2 API button.

  2. Make sure you have Fulfillment set for the URL for your webhook, and that you have it turned on for the Intent you're testing with.




回答2:


If you have Webhook enabled for your intent,Please make sure you add the line 'WebhookClient.add('This is a sample response') because when Webhooks are enabled for an intent,it expects that the user has set some response inside the webhook intent handler.Also make sure that the add() is not inside any condition statements like if or whileetc.

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
    const agent = new WebhookClient({request, response});
function webhookIntent(agent)
{
    //All your custom logics.
    //Ensure the below line is not inside any conditional statements 
    agent.add(`You should hear this response without any error!`);
}
}

Or

If you're not using webhooks in your intent,Make sure you have default response set in your intent.

I hope this helps!



来源:https://stackoverflow.com/questions/51004983/malformed-response-final-response-must-be-set

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