How to Embed Facebook Message Buttons in your Website?

       Email has always been the preferred mode for reaching out to people on the Internet. Websites would put their email addresses on web pages and made them clickable hyperlinks using the mailto protocol. Things have changed and while email is still considered important, the new generation is known to prefer instant texting apps like Facebook Messenger over email. For them, writing an email is as boring as creating a résumé.
This step-by-step guide explains the various techniques that you can use to easily embed the Facebook Messenger button in your website. When someone clicks the Message Me button, it will directly launch the Facebook Messenger app on their mobile phone or the messenger.com website if they are on the desktop. You can choose to receive messages in your Facebook profile or your Facebook page, if you have one.

A: Simple Facebook Messenger Link

The default Facebook Messenger button is rendered using JavaScript but you can also write them in pure HTML without requiring JavaScript. The advantage is that these buttons (see demo) would show up even if the user has enabled ad blockers and second, you can embed message links inside email newsletters.
Facebook Messenger
All you have to do is replace “XYZ” in the snippet below with your Facebook vanity username. If you don’t have a username yet, you can use your numerical Facebook profile ID instead. The link may be customized with CSS to resemble a button as seen in this live demo.


  1. <a href="https://m.me/XYZ">
  2. Message us on Facebook
  3. </a>
Tip: If you are not seeing messages sent to your Facebook profile, it is because Facebook automatically hides messages from people that are not in your contacts / friends list. Go to facebook.com/messages, click the “More” dropdown and choose “Filtered” to see all messages that are not in your main inbox.

B: Facebook Messenger Button

This is the default Facebook Messenger button (see live demo) rendered with JavaScript. Unlike the previous option that allows messaging to personal profile as well, this button is only available to Facebook Page owners for them to receive messages from other Facebook users.
To get started, copy-paste the following snippet in your blog template but remember to replace “XYZ” with the numeric ID of you Facebook Page. You can set the color as white for a blue text on white background button.
  1. <script>
  2. window.fbAsyncInit = function() {
  3. FB.init({
  4. appId : '95100348886',
  5. xfbml : true,
  6. version : 'v2.6'
  7. });
  8. };
  9.  
  10. (function(d, s, id){
  11. var js, fjs = d.getElementsByTagName(s)[0];
  12. if (d.getElementById(id)) {return;}
  13. js = d.createElement(s); js.id = id;
  14. js.src = "//connect.facebook.net/en_US/sdk.js";
  15. fjs.parentNode.insertBefore(js, fjs);
  16. }(document, 'script', 'facebook-jssdk'));
  17. </script>
  18.  
  19. <div class="fb-messengermessageus"
  20. messenger_app_id="95100348886"
  21. page_id="XYZ"
  22. color="blue"
  23. size="large">
  24. </div>
Tip: If you are unable to use the Facebook Messenger button, it is likely that your Facebook Page is configured to not receive messages. Go to your Facebook Page settings, choose General, Messages and turn on the option that says “Allow people to contact my Page privately by showing the Message button”.

C: Facebook Messenger Box

You have seen the Facebook Like box embedded in websites but did you know that the same box can also include an inline form allowing any Facebook user to contact you without even leaving your webpage. Here’s a live demo.
In this case you need to replace “XYZ” in the snippet below with the vanity username or ID of your Facebook Page. Anyone who is logged into Facebook can message you from your website itself, similar to regular contact us forms.


  1. <script>
  2. window.fbAsyncInit = function() {
  3. FB.init({
  4. appId : '95100348886',
  5. xfbml : true,
  6. version : 'v2.6'
  7. });
  8. };
  9.  
  10. (function(d, s, id){
  11. var js, fjs = d.getElementsByTagName(s)[0];
  12. if (d.getElementById(id)) {return;}
  13. js = d.createElement(s); js.id = id;
  14. js.src = "//connect.facebook.net/en_US/sdk.js";
  15. fjs.parentNode.insertBefore(js, fjs);
  16. }(document, 'script', 'facebook-jssdk'));
  17. </script>
  18.  
  19. <div class="fb-page"
  20. data-href="https://www.facebook.com/XZY/"
  21. data-tabs="messages"
  22. data-width="400"
  23. data-height="300"
  24. data-small-header="true">
  25. <div class="fb-xfbml-parse-ignore">
  26. <blockquote></blockquote>
  27. </div>
  28. </div>
You should also check the Facebook Page Plugin to learn about all the other configuration options that can be easily set using the data attributes.
Courtesy : www.labnol.org
To get new updates Like us on FaceBook

No comments: