1

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.

Prisoner
  • 49,922
  • 7
  • 53
  • 105
foxtdev
  • 161
  • 1
  • 15
  • Please share the relevant parts of your webhook code. Just a wild guess, does the name of your intent in Dialogflow console match a string in app.intent? If it does not match, you may need to delete the intent in the console and recreate it. Try that. – Mark Scheel Jun 24 '18 at 01:27
  • If you are testing this through the Simulator, please update your question to include the contents of the "Debug' tab. – Prisoner Jun 24 '18 at 02:27

2 Answers2

2

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.

    enter image description here

  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.

Prisoner
  • 49,922
  • 7
  • 53
  • 105
0

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!

vasanth kumar
  • 235
  • 1
  • 3
  • 13