Platforms: Facebook

At A Glance

Facebook Messenger bots launched in 2016 and has quickly emerged as a popular, fully-featured chatbot platform. Dexter bots for Facebook are built on top of the robust Messenger Platform part of the overall Facebook Developer and Pages ecosystem.

If all this looks scary and intimidating, or maybe you've even tried deploying a bot to Facebook before, don't worry! All of Dexter's platform configuration walkthroughs give you a step-by-step tutorial through in the configuration process so you don't have to worry about anything to do with coding or servers. Please also note all Messenger bots built on Dexter must comply with Facebook's messaging policies.

After you've followed our step-by-step deployment guide, read below for some pointers that every Facebook Messenger bot creator should know.

Best Practices

Messaging Your Bot

There are several ways to reach your bot:

Pro-tip: If you haven’t already, don’t forget to set a username for your Facebook page!

Add a “Send Message” button to your Page

To call attention to the existence of your bot from your Facebook Page, we recommend setting “Send Message” as your page’s primary CTA.

Facebook Send Message CTA button

User Names

The _userFirstName, _userLastName, and _userFullName data fields are automatically populated for use in Facebook bot responses. Learn more about available pre-populated namespace variables from Facebook.

+ hello
- Hi <get _userFirstName>! Thanks for messaging me.

Entry Points for Messenger Bots

There are few ways to reach your Messenger Bot, the most common of which are:

Referral Params

The aforementioned entry points allow bot developers pass in additional parameters that we capture in namespace variables for use in your bot script. Learn more about referral parameters here.


Troubleshooting

I am having difficulties deploying my bot on Facebook.

I can't deploy to my personal page.

Facebook won't let you deploy bots a personal page. To deploy a bot to a page, create a new business page on Facebook here.

I can’t find my bot in Messenger Search.

Bots are not discoverable to the general public until the app is approved. While in Development Mode, only Developers, Moderators, Administrators, or Testers can find the bot through search.

If your bot hasn't been messaged in a while, Facebook may unpublish your bot making it unavailable to the public. Visit your Facebook Page settings to re-publish any inactive Facebook pages.

I can't find my bot on my Facebook page.

The easiest way to find the bot for your Facebook page is to add a "Send Message" button as your primary call-to-action button.

My bot doesn't respond to a user.

I am seeing a "An active access token must be used to query information about the current user" error while trying to deploy my bot on Dexter.

If you successfully authenticated a Facebook user to your app in a previous step, but that user is not the creator, admin, or have any other role in your app, you may see this error while deploying. Add this user to a role for your app and try to deploy again.

I am seeing a "Attachment size exceeds allowable limit" error. Facebook is not rendering my image or video files.

There does not seem to be an official limit on image size. Keeping them under 10MB is advisable to keep the bot speedy. The max message attachment size is 25MB. In short, you shouldtry out your media files with your deployed Facebook bot to make sure they render well.

I am seeing a "Cannot message users who are not admins, developers or testers of the app until pages_messaging permission is reviewed and the app is live." error.

In order to authenticate and deploy a Messenger bot on Dexter, make sure you are either Admin or Editor on the Facebook page associated with the Page Id.

I am seeing a "Error validating access token: The session has been invalidated because the user changed their password or Facebook has changed the session for security reasons." error.

Have you recently changed your Facebook password? You will need to reauthenticate your Facebook bot. Click Undeploy and then Re-Authenticate on your Platforms > Facebook page.

I am seeing a "Length of param message[text] must be less than or equal to 640" error.

Facebook requires text messages to be UTF-8 and be shorter to 640 characters.

I am seeing a "Message cannot be empty, must provide valid attachment or text" error.

Facebook requires each response to include text. Make sure that your response includes text. This can be tricky if the given response has a combination of directions, topic redirects, or trigger redirects. Remember that <set> directions and topic redirects do not return text. Also, be careful about your use of multiple <send> and <delay> directions concurrently.

I am seeing "OAuthException: Code 2500" errors.

If you see an error message with "code":2500 when trying to deploy, double check that the Facebook Page that you're trying to use with Dexter is under your control. This error is sometimes surfaced when you aren't an admin of the Page.

I am seeing "To use 'Page Public Content Access', your use of this endpoint must be reviewed and approved by Facebook." errors.

To deploy a Dexter bot on Messenger, the Facebook app must first be private. On your Facebook app console, make sure that the app's has a "Status: In Development" when deploying. After deploying on Facebook, you can then toggle the app back to "Status: Live".

I want a Facebook Page username so that I can access my bot at m.me/PAGE_USERNAME instead of at m.me/PAGE_ID.

To be eligible to create a unique username for your Facebook Page, your page needs 25 page likes.

How long does Facebook approval take? How can I make sure my bot passes Facebook approval?

In general, we find that the Facebook approval process takes less time than they claim (which is sometimes 5–10 days). Usually it turns around in a handful of business days, but it does vary. One tactic to make sure it goes smoothly is ensuring your answers to their questions about what the bot responds with is as precise as possible.