Set up Facebook Messenger
To install Facebook Messenger as a channel for MessageBird’s Programmable Conversations, you’ll need a few credentials: your Page ID and access token, as well as your App ID and secret. In this quickstart, you’ll learn how to get all the credentials you need—by easily setting up your Facebook page and app—and how to install Facebook Messenger as a channel.
What exactly are a Facebook page and a Facebook app?
- A Facebook page: This page represents the identity of your end of the conversation. Your received and sent messages with users through Programmable Conversations will appear on your Facebook page. MessageBird uses the API to send and receive messages on behalf of your Facebook page.
- A Facebook app: This app provides the necessary credentials to access the Facebook API—you can use an existing app or create a new one just for this purpose.
Before we begin, open a new document in your favorite text editor (Google Docs, Apple notes, Microsoft Word, etc.) as a destination for copy-paste. You’ll collect a few bits of information that we’ll use later in the process.
Step 1: Create a Facebook Page
You don’t need to create a new Facebook page if you already have one. For example, if you have a page for your business that people already send messages to, you can connect this page to MessageBird to manage these conversations programmatically. However, you may want to create a new Facebook page for testing before using Conversations in production; if so, please follow the three steps below:
- Log in to your personal Facebook account.
- Click the ‘Create’ button in the top-right corner and choose ‘Page’.
- Follow the instructions. You can skip all the fields that are not required; the bare minimum of information is sufficient to get a page ready for Facebook Messenger.
Step 2: Get your Facebook Page ID
Done with setting up your Facebook page? Great, now follow these steps to get your Facebook Page ID:
- Open your existing Facebook page or the one you just created, while you’re logged in as a page admin.
- Go to the sidebar on the left-hand side of your screen and click on 'About' (you may have to make it visible with 'See more').
- Scroll down to the end of the page until you see 'Page ID'.
- Copy the ID and paste it to your text document. We’ll need it later.
Step 3: Create a Facebook App
If you already have a Facebook App, go to Step 4. If you don’t have a Facebook app yet, follow these steps:
- Go to the Facebook Developers website.
- If it’s your first time, you’ll see a ‘Getting Started’ button in the top-right corner, where you can create your developer account. Follow the instructions.
- If you’ve already signed up to be a Facebook developer, click on ‘My Apps’ and then 'Create App'.
- The name you choose won’t get displayed anywhere if you only use this app for Messenger. Make sure to pick a name that is easily recognizable for yourself and your team.
Step 4: Get your Facebook App ID and Secret
Awesome! We are almost done. Follow these steps to get your Facebook App ID and Secret:
- On the Facebook Developers website, open your app. If you’ve just created your app in the previous step, you’re already in the right place.
- Expand ‘Settings’ and hit on ‘Basic’.
- Copy your App ID and paste it into your text document. We’ll need it later.
- Reveal your App Secret with the ‘Show’ button and paste it into the text document. We’ll need it later as well.
Step 5: Connect your Facebook App and Page
It’s time to connect your Facebook page and app so your Facebook app can act on behalf of your page. To do so, we need to enable the Messenger product for the app:
Click on the ‘+’ button next to Products and choose to ‘Set up’ Messenger.
After adding the product for the first time, you need to go through a consent dialog once to provide all the necessary permissions. To do so, click on the ‘Edit Permissions’ button.
On the first page of the consent, confirm your identity by clicking on ‘Continue as (your name)’.
Select the page that you want to grant permissions for, that is, the page that you want to use as your Messenger identity. Confirm by hitting up ‘Next’.
- Make sure that the Messenger permissions are activated and confirm with 'Done'. You can ignore the warning about the app review for now.
- Done? Great! Select your page from the dropdown menu, and you’ll see that Facebook generated a page access token.
- Copy the page access token and paste it into your text document. We’ll need it later.
Don’t close this page yet; you’ll need it again to set up your webhooks.
Step 6: Install Facebook Messenger as a channel with MessageBird
Time to set up Facebook Messenger as a channel with MessageBird! Don’t forget to keep your Facebook Developers page and text document open.
- Follow our Install Channel: Facebook Messenger quickstart. Copy and paste your Page ID, Page Access Token, App ID, and App Secret that you collected in your text document into the appropriate fields. On the last step, copy the webhook URL before clicking on ‘Install Channel’.
- Go back to the Facebook Developers tab and hit ‘Subscribe to Events’.
- In the panel that just opened, paste the webhook URL from MessageBird and tick all boxes. Don’t click on ‘Verify and Save’ yet.
- Go to your 'Channels' in the MessageBird Dashboard, and open Facebook Messenger again. Copy the verification token and paste it into the webhook panel on Facebook. Hit ‘Verify and Save’ to confirm.
- Almost there! Now you just need to subscribe to events for your page so that MessageBird receives the respective webhooks. Select your page from the dropdown menu and confirm with ‘Subscribe’.
Nice work! 🎉
Your Facebook Messenger integration is now good to go! You can test it by sending a Facebook message from a personal account to your page. It should appear under your ‘Conversations’ in the MessageBird Dashboard.