Messenger

Creating a Facebook Messenger bot is easy.

To begin, check out our Getting Started guide to create a new bot, and select "Facebook Messenger" as your bot's medium.

Follow the prompts in the Create Bot wizard to configure your Facebook Application to work with Motion AI.

It is very important that you follow the instructions and paste the exact tokens and URLs when prompted to ensure Motion AI is able to communicate with Facebook on your behalf.

Referencing Facebook Profile Names

Within your conversation flow, you may include [[fbFirstName]] or [[fbLastName]] to display the user's first or last name, respectively.

Testing Your Bot

If you have deployed your bot using the Deploy to FB via Motion AI button, your bot is live immediately after deployment. Click "Deployed to Messenger" to open a Messenger chat with your Facebook Page!

If you have deployed your bot to a pre-existing Facebook Application (not using the Deploy through FB via Motion AI button) only Facebook Users who have administrator access to your Facebook app and to your Facebook Page will be able to communicate with your bot via Messenger initially. While testing, click "Deployed to Messenger" to open a Messenger chat with your Facebook Page. Your bot will be publicly available only after it has been approved through Facebook's App Review process. See below for more information.

Embedding a "Send to Messenger" Plugin on your Site

Facebook has created "Send to Messenger" plugins that allow you to authenticate users from your website and send them a message through Messenger.

Below is code you may use to display this plugin. Please see the code comments inline and change the variables to your bot credentials.


<!DOCTYPE html>
<html>
<body>
  <script>
    window.fbAsyncInit = function() {
      FB.init({
        appId: "182222305144028",
        xfbml: true,
        version: "v2.6"
      });
    };
    (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 = "//connect.facebook.net/en_US/sdk.js";
       fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
  </script>

  <!--
    `messenger_app_id` = leave this as-is, this is Motion AI's Facebook App ID.
    `page_id` = Your Facebook Page ID (retrieved from Bot Settings)
    `data-ref` = Your desired starting module ID (the message to send the user by default when they click the Send to Messenger button)

		Edit the attributes below to match your requirements
  -->
  <div class="fb-send-to-messenger"
    messenger_app_id="182222305144028"
    page_id="179294088838932"
    data-ref="44742"
    color="blue"
    size="xlarge">
  </div>
</body>
</html>

For additional information, see Facebook's official Documentation.

Linking to Your Bot and the Referral Parameter

Facebook supports linking to your Messenger bot via m.me Links, which take the form of http://m.me/PAGE_NAME, where PAGE_NAME is the Facebook Page ID (retrieved in Bot Settings) or Username for your bot's Facebook Page.

You can also send a message directly to your bot when a user follows your m.me link by adding a referral parameter to the URL in the form of ref=myparam, where myparam is the message your bot will receive. You can construct URLs such as http://m.me/mybotpage?ref=help to pass help to your bot. This enables deep linking into your bot's flow with the use of Global Connections.

Note

The "Get Started" button for new users (those who have not previously interacted with your bot) must be enabled in order for your bot to recognize referral parameters. Be sure that the Display "Get Started" button on Facebook Messenger? option is checked in Bot Settings.

Deploying Bots Using Your Own Facebook App

By default, Motion AI lets you deploy your bot instantly through our own Facebook application, using an access token we generate on your behalf.

However, if you deploy your bot through an existing app on Facebook that you created, you will have to submit your bot to Facebook for App Review before it is available to users without administrator access.

Click here to read more about the App Review process.

Messenger

Creating a Facebook Messenger bot is easy.