How to solve “Send to messenger” Plugin problem?

I have the "send to messenger" plugin that supposed to work, but doesn’t work. If this helps you in any way that would be supreme.

My page:

<body>
   <script>
    window.fbAsyncInit = function () {
        FB.init({
            xfbml: true,
            version: 'v9.0'
        });

        FB.Event.subscribe('send_to_messenger', function (e) {
            console.log(e);
        });
    };

    (function (d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = 'https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js';
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>


<div class="fb-send-to-messenger" messenger_app_id="XXXX" page_id="XXXX"  
    data-ref="anything" color="blue" size="large">
</div>
</body>

The Django view implementation:

class MyBot(generic.View):
    # verify Facebook token
    def get(self, request, *args, **kwargs):
        return HttpResponse(verify_fb_token(self.request.GET['hub.verify_token'], self.request.GET['hub.challenge']))
    
    # The dispatch method for attempting to delegate to a method that matches the HTTP method
    def dispatch(self, request, *args, **kwargs):
        return generic.View.dispatch(self, request, *args, **kwargs)

    # Post function to handle messages
    def post(self, request, *args, **kwargs):
        # Converts the text payload into a python dictionary
        incoming_message = json.loads(self.request.body.decode('utf-8'))
        for entry in incoming_message['entry']:
            for message in entry['messaging']:
                print(message)
                if 'message' in message:
                    try:
                        if 'quick_reply' in  message['message']:
                            pass...
                    except Exception as e:
                        print(e)

        return HttpResponse()

I added my webhook to the whitelist, as well as, I allowed the cookies.
I used everything in production (Heroku PasS), but the same, the button not showing.

There is something I missed?

Thanks in advance

Source: Facebook SDK Questions

LEAVE A COMMENT