Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dialogflow send custom payload json from webhook

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.

like image 210
Wassim Seifeddine Avatar asked Jul 01 '19 14:07

Wassim Seifeddine


2 Answers

{
    "fulfillmentText": "Your text response",
    "fulfillmentMessages": [
        {
            // this item is optional
            "text": {
                "text": [
                    "Your text response"
                ]
            }
        },
        {
            "payload": {
                // Your custom fields payload
            }
        }
    ]
}
like image 181
Giovanni de Luca Avatar answered Sep 30 '22 15:09

Giovanni de Luca


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.

like image 42
gmolau Avatar answered Sep 30 '22 17:09

gmolau