Connect a bot to Facebook

You can configure your bot to communicate with people through Facebook Messenger or Facebook Workplace. This article describes how to create a Facebook app using the Meta for Developers site, connect your bot to your Facebook app in Azure, and test your bot on Facebook.

This article shows how to add the Facebook channel to your bot via Azure portal. For information on how to use a custom channel adapter, see Additional information.


  • An Azure subscription. If you don't already have one, create a free account before you begin.
  • A bot published to Azure that you want to connect to Facebook.
  • A Facebook for Developers account. If you don't have an account, you can create one at
  • To use Facebook Workplace with your bot, you must create a Workplace account and a custom integration to connect the bot to.

Create a Facebook app

Users will access your bot from a Facebook Page. To connect the bot, you'll enable Facebook Messenger on the Facebook Page and then connect the bot to the Page.

Get the Page ID

  1. Sign in to your Meta for Developers account.
  2. Go to the Page on which users will access your bot. If you don't have one yet, go to Pages and select Create new Page.
  3. Open the Page's About page, then copy and save the Page ID.

Create your app

  1. Go to Create a new Facebook App.
  2. On the Select an app type page, select Business and then Next.
  3. On the Provide basic information page, enter a name for your app and select Create app.
    • If prompted, enter your password and select Submit to create your app.
    • After your app is created, the site goes to a page for your app.
  4. Expand Settings and select Basic.
    1. Copy and save the App ID and App Secret.
  5. Now under Settings, select Advanced.
    1. In the resulting pane, scroll down to the Security settings, and enable Allow API Access to app settings.
    2. Select Save Changes.

Enable Messenger

  1. Select Dashboard.
  2. In the resulting pane, scroll down to the Messenger tile and select Set Up.
  3. The site adds Messenger settings to your app and display the settings page.

Add pages and generate tokens

  1. Scroll down to the Access Tokens section and select Add or Remove Pages.
    1. When prompted for the identity to associate with Messenger, either continue with your current account or sign in to another.
    2. When prompted for the Pages you want to use with your app, select the pages and then select Next.
    3. If prompted to submit the request for Login Review, review the information and select Done.
    4. On success, the site displays a success pages. Select OK to continue.
  2. The Page you added now appears in the Pages list.
  3. Select Generate token for the Page.
    1. The site displays security information and gives you a chance to copy the token.
    2. Read and acknowledge the warning.
    3. Copy the token and select Done.

You now have your app information and a token for the next step. Leave the Facebook setting steps pending. You'll update them later.

Configure your bot in Azure

To let your bot send messages and other events to Facebook Messenger, enable webhooks integration.

  1. In a new browser window, go to the Azure portal.
  2. Open the Azure Bot resource blade for your bot.
  3. Open Channels and select Facebook.
  4. In Configure Facebook Channel, enter the Facebook information you copied in the previous steps.
    1. Enter your Facebook App ID and Facebook App Secret.
    2. Enter your Page ID and Access Token.
    3. Copy the generated callback URL and verify token values.
    4. Select Add.


  • If you don't have a copy of your information from the previous steps, you can retrieve it for the Meta for Developers site.
  • If you need to, create a new web token for the page. For instructions, see Add pages and generate tokens.

Enable webhooks

Go back to the Facebook settings to finish up the configuration process.

  1. On the Meta for Developers site, go back to the Messenger settings page for your app.
  2. In the resulting pane, scroll down to the Webhooks section and select Add Callback URL.
  3. On the Edit Callback URL page:
    1. Enter the callback URL and verify token values that you copied from the Azure portal.
    2. Select Verify and save.
  4. The Page you added now appears in the Pages list under Webhooks.
  5. Select Add subscriptions for the Page.
    1. On the Edit page subscriptions page, select the following subscription fields:
      • messages
      • messaging_postbacks
      • messaging_options
      • message_deliveries
    2. Select Save.
  6. The site displays the added subscription fields next to the Page for your bot.

Make your app public

Submit for review

Facebook requires a Privacy Policy URL and Terms of Service URL on its basic app settings page. The Code of Conduct page contains third party resource links to help create a privacy policy. The Terms of Use page contains sample terms to help create an appropriate Terms of Service document.

After the bot is finished, Facebook has its own review process for apps that are published to Messenger. The bot will be tested to ensure it's compliant with Facebook's Platform Policies.

Make the app public and publish the Page


Until an app is published, it's in Development Mode. Plugin and API functionality will only work for admins, developers, and testers.

After the review is successful, in the App Dashboard under App Review, set the app to Public. Ensure that the Facebook Page associated with this bot is published. Status appears in Pages settings.

Set the API version

If you receive a notification from Facebook about deprecation of a certain version of the Graph API:

  1. Go to Meta for Developers.
  2. Go to the app your created for your bot.
  3. Under Settings, select Advanced.
  4. Select Upgrade API version, then switch Upgrade All Calls to version 4.0.

Test the connection by following the steps described in the Test your bot in Facebook section.

Test your bot in Facebook

You can now test whether your bot is connected to Facebook correctly by sending a message via the Facebook Page you associated with your new Facebook app.

  1. Go to your Facebook Page.
  2. Select Add a button.
  3. On the Edit action button page, select Send message.
    1. On the Frequently asked questions page, review the default question and answer, then select Save.
    2. The site replaces the previous Edit action button with a new Edit Send message button.
  4. Select Edit Send message then select Test button.
    1. The site displays your Page with the sample question as a suggested action.
    2. Enter any message you want to test the connection to your bot.

You can also test this feature using the sample bot for the Facebook adapter by populating the appsettings.json file with the same values described in the steps above.

Additional information

See the Bot Framework C# Facebook-events sample for a sample bot that supports Facebook Messenger communication.

For Facebook Messenger documentation, see:

For Facebook Workplace documentation, see:

Connect a bot to Facebook using the Facebook adapter

The custom channel adapter for Facebook is available for JavaScript/Node.js or C#/.NET. The README describes how to add it to your bot.

  • To connect to Facebook Workplace, your bot must use the custom channel adapter.
  • To connect to Facebook Messenger, your bot can use the Azure channel or the custom channel adapter.

To complete configuration of your Facebook app for a bot that uses the custom channel adapter:

  1. Within the dashboard for your app, select Messenger and then select Settings.

  2. In the Webhooks section, select Add Callback URL.

  3. In the Callback URL text box enter the Facebook endpoint for your bot. For example,

  4. In the Verify Token text box enter the verify token you created earlier and used in your bot application's appsettings.json file.

  5. Make sure your bot is running, and then select Verify and Save to verify your callback URL.

  6. Once your callback URL has been verified, select Add Subscriptions that is now shown. In the pop-up window, choose the following subscriptions and select Save.

    • messages
    • messaging_postbacks
    • messaging_optins
    • messaging_deliveries