5
votes

From Dialogflow console, i can set a custom payload like this

enter image description here

How can i send the exact same response from a webhook custom integration.

I tried sending it from Flask as JSON but it didn't work.

2

2 Answers

4
votes
{
    "fulfillmentText": "Your text response",
    "fulfillmentMessages": [
        {
            // this item is optional
            "text": {
                "text": [
                    "Your text response"
                ]
            }
        },
        {
            "payload": {
                // Your custom fields payload
            }
        }
    ]
}
1
votes

When you are using a webhook you have to send back a complete WebhookResponse. Unfortunately, the documentation for the webhook protocol seems to have gone missing when they migrated the documentation from dialogflow.com to cloud.google.com/dialogflow. However, it is still available in the Dialogflow Discovery document. If you look for the GoogleCloudDialogflowV2WebhookResponse there you'll see that you would have to send back something like this:

{
    "payload": {
        "facebook": {
            "attachment": {
                # ... etc.
            }
        },
        "slack": {}  # ... etc.
    }
}

The format for version v2beta1 of the Dialogflow API is the same.