> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognigy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Facebook (Meta) Messenger

<Frame>
  <img class="image-center" src="https://mintcdn.com/cognigy-15abf2ba/gMdd3UtLaZzJw9j6/_assets/ai/deploy/endpoint-reference/facebook-messenger.png?fit=max&auto=format&n=gMdd3UtLaZzJw9j6&q=85&s=825d060afda65027225e0f601d2dce89" alt="Facebook Messenger Endpoint logo" width="337" height="63" data-path="_assets/ai/deploy/endpoint-reference/facebook-messenger.png" />
</Frame>

The Facebook Messenger Endpoint enables you to connect AI Agents to the [Facebook Messenger](https://www.messenger.com/) platform.

## Prerequisites

* A Facebook account.
* Access to [Facebook (Meta) Messenger](https://www.messenger.com/).
* Access to the [Facebook (Meta) Developer Center](https://developers.facebook.com/).

## Generic Endpoint Settings

Learn about the generic Endpoint settings on the following pages:

* [Endpoints Overview](/ai/agents/deploy/endpoints/overview)
* [Data Protection & Analytics](/ai/agents/deploy/endpoints/data-protection-and-analytics)
* [Transformer Functions](/ai/for-developers/transformers/overview)
* [NLU Connectors](/ai/platform-features/nlu/external/nlu-connectors/overview)
* [Session Management](/ai/agents/deploy/endpoints/session-management)
* [Handover Settings](/ai/agents/deploy/endpoints/handover-settings)
* [Real-Time Translation Settings](/ai/agents/deploy/endpoints/real-time-translation-settings)
* [Inject and Notify](/ai/agents/deploy/endpoints/inject-and-notify)
* [Copilot](/agent-copilot/configure/copilot-section)

## Specific Endpoint Settings

<AccordionGroup>
  <Accordion title="Facebook Page Setup">
    | Parameter                  | Description                                                                                                      |
    | -------------------------- | ---------------------------------------------------------------------------------------------------------------- |
    | Facebook Page Access Token | A token generated by your Facebook App to authenticate the connection with Cognigy.AI.                           |
    | App ID                     | The App ID of your Facebook App.                                                                                 |
    | App secret                 | The App Secret of your Facebook App. For additional security, it verifies that messages are sent from Messenger. |
  </Accordion>

  <Accordion title="Facebook Profiles">
    | Parameter               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
    | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | Request profile data    | Fetches data from the user's Facebook profile and stores in the `ci.data.profile` object. The `ci.data.profile` object will contain the following parameters: <ul><li>**Id** – the Facebook user's PSID, which is a unique user ID for each Facebook Page the user interact with.</li><li>**first\_name** – the user's first name.</li><li>**last\_name** – the user's last name.</li><li>**profile\_pic** – a URL linking to the user's profile picture.</li><li>**locale** – information about the user's locale.</li><li>**timezone** – the user's time zone.</li><li>**gender** – the user's gender.</li></ul><br />Note that the same data types are exposed in the profile object for every Facebook user. However, the actual values depend on the information available in their Facebook profile and on their privacy settings. |
    | Update contact profiles | Updates the Contact Profile in Cognigy.AI with data from the user's Facebook profile. If the setting is enabled, the information a Facebook user has on their profile will be copied to their Contact Profile.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
    | Merge contact profiles  | Each Facebook user has a user's PSID for each Facebook Page they interact with. This means that if you own two or more Facebook Pages, you can't immediately identify users across these pages because they will have a different ID for each page. However, if you enable this setting, Cognigy.AI will fetch all of a user's PSIDs for your pages and merge these profiles into one. This setting allows you to easily identify a single user across all your pages and personalize the chat experience more effectively. To perform the necessary API calls to get all the PSIDs for a user, the same Business must own all the Facebook Pages.                                                                                                                                                                                       |
  </Accordion>

  <Accordion title="Messenger Settings">
    | Parameter                | Description                                                                                                                                                                               |
    | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | Enable typing indicators | Enables a typing indicator while the bot is replying. You can configure whether typing indicators should be used and how many milliseconds of delay there should be between each message. |
    | Message Delay            | The amount of time to wait between sending bot replies, in milliseconds.                                                                                                                  |
  </Accordion>
</AccordionGroup>

## How to Set Up

<AccordionGroup>
  <Accordion title="1. Create a Facebook Page and a Facebook App">
    1. Log in to your Facebook account. Go to the **Pages** section.
    2. Click **Create New Page**, select a type (Business or Community), and provide a name and category.
    3. Go to the [Facebook (Meta) Developer Center](https://developers.facebook.com/).
    4. Click **Manage Apps**, then **Add a New App**.
    5. Fill in the required details to complete the app creation.
    6. In your app's product overview, locate **Messenger** and click **Set Up**.
  </Accordion>

  <Accordion title="2. Generate a Page Access Token">
    1. Go to **Messenger > Access Tokens**. Add the Facebook Page created earlier.
    2. Click **Generate Token**, acknowledge the warning, and **copy the token**.
  </Accordion>

  <Accordion title="3. Create a Messenger Endpoint">
    1. In the left-side menu of the Cognigy.AI Project, go to **Deploy > Endpoints**.
    2. On the **Endpoints** page, click **+ New Endpoint**.
    3. In the **New Endpoint** section, do the following:
       1. Select the **Messenger** Endpoint type.
       2. Add a unique name.
       3. Select a relevant Flow from the list.
    4. Open the **Facebook Page Setup** section. Paste the **Page Access Token** from the Facebook App.
    5. *(Optional)* Enter your **App ID** and **App Secret** for additional security.
    6. Copy the Endpoint URL for later use.
  </Accordion>

  <Accordion title="4. Configure Webhooks">
    1. Go to the Facebook app. Under **Messenger > Webhooks**, click **Add Callback URL**.
    2. Paste the Endpoint URL as the callback URL.
    3. Enter the **Verify Token** from Cognigy.AI:
       * For `https://trial.cognigy.ai`, use the token `6a1ed94ef26462d1a529ab80afabe135e5ac7cc8b414ef762e1208f3339f887196d3433c996c0f30ea15295fbd86293cd7516abaa9b9e78d641ebb514eea32b4`.
       * For other environments, contact Cognigy technical support for more information.
    4. Click **Verify and Save**.
    5. Add **Subscription Fields**: select `messages`, `messaging_postbacks`, and optionally `messaging_referrals`. Save the settings.
  </Accordion>
</AccordionGroup>

## More Information

* [Help Center: Facebook (Meta) Messenger Intro](https://support.cognigy.com/hc/en-us/articles/360015980560-Facebook-Messenger-Intro)
* [Help Center: Facebook (Meta) Messenger Deploy an Endpoint](https://support.cognigy.com/hc/en-us/articles/360015980660-Facebook-Messenger-Deploy-an-Endpoint)
* [Help Center: Use Facebook (Meta) Handover](https://support.cognigy.com/hc/en-us/articles/360016021919-Facebook-Messenger-Use-Facebook-Handover)
* [Help Center: Facebook (Meta) Messenger Facebook Tools](https://support.cognigy.com/hc/en-us/articles/360015980780-Facebook-Messenger-Facebook-Tools)
