> [!WARNING]
>
> **Preview**
>
>
> This product or feature is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section
> of the [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1).
>
> Pre-GA products and features are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).

Using the Meta Workplace integration, you can create a Meta Workplace bot to
interact with your users.


> [!NOTE]
> **Note:** When using a third party integration, requests and end-user data are sent to both Google and the third party. The terms of service, SLA, pricing, and quotas [for your agent edition](https://docs.cloud.google.com/dialogflow/docs/editions) are applicable for Google's handling of these requests. The third party's terms of service, SLA, pricing, and quotas are applicable for the third party's handling of these requests.

<br />

## How it works

This is how the integration works:

- You create a customer integration that uses [Meta Workplace](https://developers.facebook.com/docs/workplace/).
- You configure the Dialogflow CX integration and Workplace instance so that they communicate with each other.
- The Dialogflow CX integration sends messages to your users using the [Send API from Meta](https://developers.facebook.com/docs/messenger-platform/reference/send-api/).
- The Dialogflow CX integration receives messages from your users by acting as the [Workplace Webhook from Meta](https://developers.facebook.com/docs/workplace/reference/webhooks/).

## Setup

> [!NOTE]
> **Note:** Make sure that [billing is enabled](https://docs.cloud.google.com/dialogflow/cx/docs/quick/setup#billing) on your project before testing the integration.

To set up the integration:

1. Follow the steps to create a Meta Workplace Custom Integration using [Creating a Meta Workplace Custom Integration](https://www.workplace.com/resources/tech/integrations/chat-bot):
   - Create a Meta Workplace Custom Integration.
   - Copy the App Secret provided at this step. You'll use this token to configure the integration from the Dialogflow CX console.
   - Create or reset the access token for your integration, and copy it. You'll use this token to configure the integration from the Dialogflow CX console.
   - Set up the Custom Integration permissions. Make sure `Message any member` is enabled in permissions.
2. Configure the integration from the Dialogflow CX console:
   1. Go to the [Dialogflow CX console](https://dialogflow.cloud.google.com/cx/projects).
   2. Go to the **Manage** tab on the navigational menu.
   3. Select **Integrations**.
   4. Click the **Connect** button on the **Meta Workplace** tile.
   5. A configuration dialog opens:
      - **App secret:** Enter the app secret from [App Dashboard Basic Settings](https://developers.facebook.com/docs/development/create-an-app/app-dashboard/basic-settings/).
      - **Access token:** Enter the access token you copied during the Meta app setup.
      - **Verify token:** Enter any private token you need. Copy this value. This token configures the Meta Workplace Webhook.
      - **Webhook URL:** Copy this value. This token configures the Meta Workplace Webhook.
      - **Start:** Click **Start** to start the integration service for your agent.
3. Finish setting up the Meta Workplace integration and test it. Follow the steps in the [Webhook for Meta Workplace](https://developers.facebook.com/docs/workplace/integrations/custom-integrations/webhooks/) documentation to complete these tasks:
   - Configure the Meta webhook for your app by using the **Webhook URL** and **Verify token** values that you copied earlier.
   - Subscribe your integration to webhook topics, and make sure that you enable `messages` and `messaging_postbacks` in the page subscription.
   - Test your app.

## Rich response messages

Rich response messages are supported using **Custom Payload** in
[Fulfillment](https://docs.cloud.google.com/dialogflow/cx/docs/concept/fulfillment). For more information
about the message format, see the
[Send API Parameters Message Object](https://developers.facebook.com/docs/messenger-platform/reference/send-api#parameters).

For example, the following custom payload provides a text message:

```json
{
  "text": "Hello, world"
}
```

The following custom payload provides an image message:

```json
{
  "attachment": {
    "type": "image",
    "payload": {
      "url": "https://example.com/test.jpg"
    }
  }
}
```

## Channel-specific responses

When configured,
[channel-specific responses](https://docs.cloud.google.com/dialogflow/cx/docs/concept/fulfillment#channel-specific)
with channel `DF_CX_FB_MESSENGER` are automatically used when the agent responds
to Meta Messenger messages.