Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dialogflow V2 Facebook Messenger Generic Template Example Payload

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?

like image 810
DrDirk Avatar asked Dec 03 '17 11:12

DrDirk


People also ask

How do I create a Facebook Messenger template?

Create your message templateIn the Ad Creative section, Under Call to Action, choose Send Message. In the Message Template section, choose Create New. You can also Generate Leads to collect information from customers in a Messenger conversation. Click + Create.

Can I attach a file to Messenger?

You probably already know that you can share photos, videos, and GIFs in Facebook Messenger, but you can even send files, too, including PDFs. This method of sharing is handy if you don't have a recipient's email address readily available or if you're only connected with them through Facebook.

What is the maximum file size for Messenger?

The Messenger Platform allows you to attach assets to messages, including audio, video, images, and files. The maximum attachment size is 25 MB.


1 Answers

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"
                    }]
                }
            }
        }
    }
}]
like image 117
DrDirk Avatar answered Nov 28 '22 15:11

DrDirk