Page 1 of 1

Facebook Messenger Chat plugin Code

Posted: 31 May 2021, 17:08
by GGANG
Hello Karl,

Please help for this code to put into the Custom Javascript. What is wrong?
Code
function x3_load_page(){
      var chatbox = document.getElementById('fb-customer-chat');
      chatbox.setAttribute("page_id", "262984240902464");
      chatbox.setAttribute("attribution", "biz_inbox");
      window.fbAsyncInit = function() {
        FB.init({
          xfbml            : true,
          version          : 'v10.0'
        });
      };

      (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/th_TH/sdk/xfbml.customerchat.js';
        fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk')); 
      }
and I added this code to the Content Appened. Its not show a chat box. I want the position below right corner. Where should I add this code?
Code
<!-- Messenger Chat plugin Code -->
    <div id="fb-root"></div>

    <!-- Your Chat plugin code -->
    <div id="fb-customer-chat" class="fb-customerchat">
    </div>

Re: Facebook Messenger Chat plugin Code

Posted: 01 Jun 2021, 01:10
by mjau-mjau
You want it on all pages? If so, it shouldn't go inside x3_load_page() because that triggers on all pages. Furthermore, since this Facebook script is non-jQuery and doesn't use anything inside X3, it doesn't have to go inside any function ... Just place it in custom Javascript.

As for positioning, I don't know. First you need to get it to work. Then, I will need a link to see what it does and find a solution for position.

Re: Facebook Messenger Chat plugin Code

Posted: 06 Nov 2021, 06:25
by InoculateIT
Use this code and put it on your footer, then it works :)

Goto your business fb page, then settings then create a chat bot :)

Code
<!-- Messenger Chatplugin Code -->
    <div id="fb-root"></div>

    <!-- Your Chatplugin code -->
    <div id="fb-customer-chat" class="fb-customerchat">
    </div>

    <script>
      var chatbox = document.getElementById('fb-customer-chat');
      chatbox.setAttribute("page_id", "YourIDhere");
      chatbox.setAttribute("attribution", "biz_inbox");

      window.fbAsyncInit = function() {
        FB.init({
          xfbml            : true,
          version          : 'v12.0'
        });
      };

      (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/da_DK/sdk/xfbml.customerchat.js';
        fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));
    </script>

Re: Facebook Messenger Chat plugin Code

Posted: 07 Nov 2021, 00:51
by mjau-mjau