Download the open source Bot Libre Community Edition and install Bot Libre on your own server
Bot Libre Forum

How to Connect a Bot to Facebook Messenger

by mike2016 posted May 13 2016, 9:19

This post is out of date as of Bot Libre 9.5, see How to Connect a Bot to Facebook.

Keeping up with social media and keeping your online community engaged can be a time consuming task. Through Bot Libre you can now automate your Facebook presence with your own Facebook Messenger bot. Any Bot Libre bot can be connected to a Facebook Messenger page account. The bot will reply to your users questions in real-time using the responses of script you have trained your bot with.

Connecting a bot to Facebook is a bit of a process, as Facebook requires a lot of permissions and validation to be setup to allow a bot on their platform. This "how to" give you a step by step process to connecting your bot to Facebook Messenger.

You can also watch this video on How to create a chatbot for Facebook Messenger over here.

Step 1 - Create a Facebook Page for your bot.

After you have logged in to your Facebook account, you can create a page by clicking on "Create" on the top right menu and selecting "Page".

You must then select a category for your page. Choose a category that will make sense for your bot.

 

Fill out the details for your page to finish creating it.

 

Step 2 - Create a Facebook App for your bot.

Go to http://developers.facebook.com and click on 'Get Started'.

Click the 'Next' button to continue.

Select the best option to describe yourself on the following screen.

Now click on the 'Create First App' button.

Next, enter a Display Name and then click the 'Create App ID' button.

On the following screen, click 'Settings' in the left toolbar then select 'Basic'.

Enter "https://www.botlibre.com" into the 'App Domains' field. Note your App ID and App Secret, you will need these in following steps. 

Scroll to the bottom of this screen and click the '+ Add Platform' button.

Select 'Website' from the following popup window.

Enter "https://www.botlibre.com" into the 'Site URL' field. 

Click the 'Save Changes' button.

Next, click on 'Facebook Login' in the left toolbar, then select 'Settings.'

Enter "https://www.botlibre.com/facebook" into the 'Valid OAuth Redirect URIs' field then click the 'Save Changes' button.

Step 3 - Create a bot

Next, you will need to create a bot to connect with your Facebook Page and App. You can follow the instructions here to create your bot: How to create your own chat bot in 10 clicks

Step 4 - Connect bot with Facebook

From the Bot Libre website, browse to your bot. Go to the Admin Console by clicking on the gear icon at the bottom.

From the Admin Console, click on "Facebook" to take you to a screen to configure your Facebook settings. 

Enter the 'App ID" and "App Secret' from your Facebook App into the corresponding fields on this form.

Next, click the 'Authorize' button to authorize your bot with Facebook. Click 'Okay' to accept any permissions needed by Facebook.

Select the checkbox for the page you created in step 1, then click the 'Next' button.

Select 'Yes' for the requested permissions in the following screen.

Click 'Done' when finished.

The "Facebook User", "Access Token" and "Page" fields should now have been filled in automatically.

Click the "Connect" button to connect your bot to Facebook.

Now scroll down to "Facebook Messenger Properties" and click "Facebook Messenger app (realtime messages)" to toggle it on. Press save.

Copy the "Webhook URL" to your clipboard for use in the next step.

Step 5 - Set up Webhook URL with Facebook

Go to your Facebook App's dashboard webpage. Click on 'Products +' in the left menu.

Next, click the 'Set Up' button in the 'Messenger' panel.

Now select 'Settings' under 'Messenger' in the left menu.

Click the 'Add Callback URL' button.

Enter the 'Webhook URL' you had copied in the previous step into the 'Callback URL' field. Enter "token" into the 'Verify Token' field.

Click the "Verify and Save" button to finish.

The following window will pop up, select the checkbox next to your page and press the 'Next' button.

In the following window, check the box for 'Manage and access Page conversations on Messenger'.

Press the 'Done' button. On the dashboard below, click the 'Add Subscriptions' button next to your page.

Select the 'messages' checkbox in the following window. ** Also check 'messaging_postbacks'.

Click the 'Save' button. Scroll to the 'Access Tokens' section of the Messenger Settings page.

Click the 'Generate Token' button next to your bot's Facebook page.

Click the 'I Understand' checkbox, then copy the token to your clipboard by clicking the 'Copy' button. Click the 'Done' button to close the window.

Now return to your bot's Admin Console on the Bot Libre website. Go to the 'Facebook' tab and paste the 'Page Access Token' you had previously copied into the "Facebook Messenger Page Access Token" field.

Click the 'Save' button.

Step 6 - Approval by Facebook

At this point, you should be able to send messages to your bot's Facebook Page with the Facebook user who created the page, and your bot will respond.

For other Facebook users to be able to send and receive messages with your bot, you will need to have your Facebook App approved by Facebook.

Return to the Messenger Settings page on the Facebook Developer website and scroll to the 'App Review for Messenger' section.

Click the 'Add to Submission' buttons next to the four permissions.

You may need to complete additional details in the "App Details" tab before you can complete your submission. You will need to upload an app logo and provide a URL to your privacy policy.

You will also need to complete business or individual verification. This can be found on the 'Messenger Settings' page.

After receiving your verification information, Facebook should approve your App after some time.

Toggle the 'Off' switch to 'On' at the top of the Facebook Developer page to make your app available to the public and have other users be able to interact with your bot.

If you got this far, congratulations, you have now connected your bot to Facebook Messenger. Now you can train your bot's responses and review its conversations from its "Training & Chat Logs" page in its Admin Console. If you encountered any issues, or would like our help setting up your bot please email us at [email protected] or upgrade to our Platinum service and we can build your bot for you.


by rtcbranch80 posted Mar 30 2021, 4:09

Im done on this part (1) and I can't figure out how to go to (2)

(1) Enter the 'App ID" and "App Secret' from your Facebook App into the corresponding fields on this form.

(2) Next, click the 'Authorize' button to authorize your bot with Facebook. Click 'Okay' to accept any permissions needed by Facebook.


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1440, today: 0, week: 0, month: 52

by admin posted Mar 30 2021, 10:24
What happens when you click the Authorize button? (from your bot's Facebook page in its Admin Console)

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1490, today: 1, week: 1, month: 61

by rtcbranch80 posted Mar 30 2021, 20:15

I figiured out my previous issue now Im on step 6 and I cant find the "App review for Messenger" Part, and what I did was to search the four items that needs the "add subscription" but theres no option for that only standard and advanced access..so i clicked request advanced access instead..

maybe the facebook developer menu was updated?

 

I tried messaging the page connected with my bot but, it does not auto reply,,,no reply at all


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1456, today: 0, week: 0, month: 47

by admin posted Mar 31 2021, 8:42
To have you app reviewed click on "App Review" in the side bar, then "Request permission or features".

If you need help connecting your bot with Facebook contact [email protected]

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1497, today: 0, week: 0, month: 60

Id: 12742773
Tags: blog, how to, facebook, messenger, social media
Posted: May 13 2016, 9:19
Updated: Nov 14 2022, 11:07
Replies: 4
Views: 22384, today: 1, week: 1, month: 278
3 0 5.0/5