Facebook

You can set up your bot to interact with users through Facebook Messenger. This section explains how to create a Facebook app on the Facebook for Developers site and connect it to your bot in the Druid Portal.

Prerequisites

Before configuring the Facebook channel, ensure you have:

  • A published Druid bot.
  • One or more Facebook pages.
  • Open the Facebook Page's About page and then copy and save the Page ID.
IMPORTANT!
  • For DRUID hybrid and cloud deployments, the Facebook channel requires the Microsoft Bot Framework. You can configure the channel only if the Bot Framework is enabled on your tenant. If the channel configuration is unavailable – the Post Office is set to BotService (Bot Details → General) – contact Druid Support to enable the Microsoft Bot Framework on your tenant.
  • For Druid on premise deployments, the channel uses direct DRUID Facebook integration. Ensure network access is configured for the following messaging endpoints:
  • Outbound graph.facebook.com 
    Inbound DRUID.BotApp
NOTE: The Facebook channel has a limitation on file transfer, it only supports common media files (images or video). Other file formats like .doc, .docx, .txt or .xslx (etc.) will be altered and corrupted both on file upload or when generated by chatbots.

Connect a bot to Facebook

NOTE: The Facebook UI may appear slightly different depending on which version you are using.

To connect a bot with Facebook Messenger, follow these steps:

Step 1. Create a Facebook app

  1. In your browser, navigate to Facebook for Developers and log in.
  2. On the toolbar, click My Apps. Your Facebook apps page appears.
  3. Click the Create App button.
  4. Select the business portfolio (verified or unverified) that you want to connect to your app.

  5. Click Next.
  6. Select Other as the use case. You can customize how your app interacts with Meta later on the app Dashboard.

  7. Click Next.
  8. Select Business as the app type. Your app type determines which products and APIs are available to your app. For more information on the app type, see Facebook documentation.
  9. Click Next.
  10. Enter an app name and the email address to be used to contact you about this particular app.

  11. Optionally, you can link this app to an existing Business portfolio using the drop-down menu, or you can add this later.

  12. Click Create app.
  13. For security reasons, re-enter your password and click Submit.

The Add products to your app page appears. You can now customize the way you interact with people on Messenger. For more information, see the next step.

Step 2. Set up Messenger for your app

In this section you will enable Messenger. connect your app to a Facebook Page and generate an access token for the FB page:

  1. On the Add Products to Your App page, search for Messenger and click the Set Up button. The Messenger API Setup appears.
  2. Scroll-down to the Generate access tokens section and click Connect.
  3. Continue as logged in user or log in using another account.
  4. Select the target Facebook page and click Continue.
  5. When prompted to review the app's permission requests, click Save.
  6. A pop-up appears informing you that you linked your Facebook app to Facebook.

  7. Click Got it.
  8. The connected Facebook page appears on the Messenger API Setup.

  9. Click the Generate button to generate an access token for your FB page. The Token Generation pop-up appears.
  10. Tick I understand, then click the Copy button to copy the page access token and save it for use at Step 4.

  11. Click Done.

Step 3. Get your Facebook app details

  1. In Facebook for Developers Portal, go to your Facebook app settings.
  2. On the main menu, click App settings > Basic.
  3. Click Show and enter your FB password to reveal the App ID. Copy the App ID and App secret and save them for use in Step 4.
  4. Click Save changes.
  5. On the main menu, click Settings > Advanced.
  6. In the right pane, tap on Allow API Access to app settings.
  7. Click Save changes.

Step 4: Configure the DRUID bot

  1. Log in to the Druid Portal and select your bot.
  2. Click the Channels tab, then click the Facebook card.
  3. The channel configuration modal appears.

  4. Enter the Facebook App ID and the Facebook App Secret. Use the App ID and App Secret you copied when creating the Facebook app.
  5. Click the Add Page button and enter the Facebook Page ID and Page Access Token and click Pave Page button.
  6. HINT: For information on how to get the Facebook Page ID, see Facebook documentation.

    If you host the bot via Facebook app in multiple Facebook pages, repeat step 4 for each additional Facebook page.

  7. Click the Publish button to activate the channel. The channel activation might take up to 1 minute.
  8. Copy the Callback URL and Verify Token and save them for use in Step 5.

After the channel activates, the following fields are available in Druid:

  • [[ChatUser]].ChannelId = "facebook"
  • [[ChatUser]].UserId - Stores an unique identifier of the Facebook user account.

Step 5: Enable webhooks and select webhooks subscriptions

In order to send messages and other events from your bot to Facebook Messenger, you must enable webhooks integration. To do so, follow these steps:

  1. In Facebook for Developers Portal, go to your Facebook app settings.
  2. On the main menu, click Messenger > API Settings.
  3. On the right pane, in the Configure webhooks section, click Configure. The Edit Callback URL pop-up appears.
  4. Enter the Callback URL and Verify Token you copied from the Druid Portal.
  5. Enter the Callback URL and Verify Token automatically generated in Druid on the bot Facebook channel and click Verify and save.
  6. The webhook appears in the Configure webhooks section, but no webhook events are selected. You need to select webhook fields for your FB app.
  7. Click the Manage button. The Webhook fields pop-up appears.
  8. Subscribe to the following webhook events: messages and messaging_postbacks. Select messaging_customer_information if you want DRUID to store the chat user's first name and last name (in [[ChatUser]].FirstName and [[ChatUser]].Lastname).
  9. Close the pop-up. The selected webhook fields appear in the section.
  10. Now you need to select webhook events for your FB page.

  11. In the Generate access tokens section, click the Add Subscriptions button. The Edit Page Subscription page appears.
  12. Select messages and messaging_postbacks. Select messaging_customer_information if you want DRUID to store the chat user's first name and last name (in [[ChatUser]].FirstName and [[ChatUser]].Lastname).
  13. Click Confirm. The selected webhook events appear in Generate access tokens section in line with your FB page.

The integration between the Druid bot and the Facebook Page is complete.

NOTE: The Facebook app is in Development Mode until you publish it. The plugin and API functionality will only work for admins, developers and testers.

Complete your Facebook app review, make the app public and publish the Facebook Page.

NOTE: In DRUID 7.5 and higher, when a user initiates a conversation with the bot, the Welcome flow will be automatically triggered. Regardless of the user's subscription status to the bot channel, the welcome message will be promptly sent to the user, ensuring a seamless and engaging interaction experience.

Inactivating the channel

To inactivate the channel, go to the Channels page and turn off the Enabled toggle on the Facebook card.