2

I get the following error in the response of Dialogflow CX webhook response

[
    {
      code: 3,
      message: 'Failed to parse webhook response: [{"fulfillment_response":{"messages":[{"text":"text here"}],"merge_behavior":"REPLACE"}}]'
    }
]

what can we do to solve this error?

Prisoner
  • 49,922
  • 7
  • 53
  • 105
Zhang Fan
  • 31
  • 1
  • 5
  • Welcome to StackOverflow! It sounds like there is an error in how you have formatted your response. Can you update your question to include the JSON you're responding with? – Prisoner Sep 05 '20 at 00:41
  • Without the content of webhook response there is no way to give an accurate solution. Please make sure that the response complies with the JSON format rules. – Gi1ber7 Sep 05 '20 at 13:07

1 Answers1

4

According to the error message you provided, the webhook response that you return from your webhook service is the following:

[{
    "fulfillment_response": {
        "messages": [{
            "text": "text here"
        }],
        "merge_behavior": "REPLACE"
    }
}]

The text field under “messages” should have a text response which should contain an array of text messages to return to the user.

An example of a webhook response is as follows:

{
        “fulfillment_response”: {
                “messages”: [{
                        “text”: {
                                “text”: [
                                        “text here”
                                ]
                        }
                }],
       “merge_behavior”: “REPLACE”
        }
}

For more information on Webhook Response, see here: https://cloud.google.com/dialogflow/cx/docs/reference/rpc/google.cloud.dialogflow.cx.v3beta1#webhookresponse

Jessica Rodriguez
  • 2,899
  • 1
  • 12
  • 27
  • please don't use smart quotes “text” in responses. if you copy/paste from mac notes or google docs it will sometimes screw up your code like this. https://www.solveyourtech.com/turn-off-smart-quotes-google-docs/ – dcsan Dec 15 '20 at 15:44