Dialogflow V2 Facebook Messenger Generic Template Example Payload
Asked Answered
K

1

5

I was working with Dialogflow V1 and decided to change to the V2 beta. The API has changed and I cannot recover my previous facebook templates I was sending to Messenger. With V1 I used:

{
    'speech': speech,
    "data": {
        "facebook": {
            "attachment": {
                "type": "template",
                "payload": {
                    "template_type": "button",
                    "text": "What do you want to do next?",
                    "buttons": [{
                        "type": "web_url",
                        "url": "https://www.messenger.com",
                        "title": "Visit Messenger"
                    }]
                }
            }
        }        
    }
}

My problem is that I do not know where the data entry should go in V2. Could somebody provide me with a working example or a link in the Dialogflow Docs where the data field is explained?

Kaciekacy answered 3/12, 2017 at 11:50 Comment(0)
K
10

OK. After some hours of trial an error I got it working. You have to pass the custom facebook payload within the webhook_response object as fullfilment_message array as payload object like so:

{'fulfillmentMessages': [{
    'payload': {
        "facebook": {
            "attachment": {
                "type": "template",
                "payload": {
                    "template_type": "button",
                    "text": "What do you want to do next?",
                    "buttons": [{
                        "type": "web_url",
                        "url": "https://www.messenger.com",
                        "title": "Visit Messenger"
                    }]
                }
            }
        }
    }
}]
Kaciekacy answered 3/12, 2017 at 13:43 Comment(1)
@AmruthPillai the API of Dialogflow is in constant development. If you want to stick with V2 you can find the from Dialogflow expected response JSON structure here.Kaciekacy

© 2022 - 2024 — McMap. All rights reserved.