Skip to main content

How to connect Facebook Messenger to an AI Agent

Integration with Facebook Messenger allows the AI agent to automatically process incoming messages from users via a company’s Facebook Page. The AI agent can carry on full conversations on behalf of the page and respond to user queries in real time.

Preparation: Create an App in Facebook Developer Console

  1. Go to Facebook for Developers.
  2. Click Create App and follow the steps in the app creation wizard.
  3. After creating the app:

After this, new configuration sections will appear in the menu.

  • Open the Add Product section from the left menu.
  • Add the following products:
    • Messenger
    • Webhooks

Obtain Tokens and Page ID

  1. Go to: Messenger → Messenger API Settings
  2. In the Generate Access Tokens section:
    • Link your desired Facebook Page.
    • Click Generate Token and save it — you’ll need it to set up the integration.
    • Also copy the Facebook Page ID for your page.

Set Up the Integration in Flametree

  1. Open the Integrations section.
  2. Find the Facebook Messenger integration type, click Add +, and fill in the fields:
FieldDescription
Name, DescriptionCustom name and description for the integration.
Facebook Page IDPage ID (from the Generate Access Tokens section).
Facebook Bot TokenGenerated token (Access Token).
Facebook Verify TokenArbitrary string for webhook verification (save it for the next step).

Switching the App to Production (Live Mode)

By default, the AI agent will only receive messages from page administrators. To make it available to all Facebook users:

  1. Go to: App Settings → Basic
  2. Fill in all required fields:
    • Display Name
    • Privacy Policy URL
    • Category
    • App Icon
  3. Toggle the switch to App Mode: Live