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

# Facebook Messenger

Deploy your agent to Facebook Messenger using the Facebook Channel integration.

### Prerequisites

* A Facebook account with access to the following resources:
  * A Facebook Page
  * A Facebook App that is connected to that Page
* Facebook Developer credentials:
  * Facebook App Secret
  * Facebook Page Access Token
* A user-defined verification token for webhook validation

### Create a Facebook Messenger channel

Use one of the following methods to define the channel.

**Using YAML:**

```yaml theme={null}
# Facebook Messenger Channel Configuration Example

spec_version: v1
kind: channel

# Required: Channel type identifier
channel: facebook

# Required: Name for this channel instance
name: production_facebook_channel

# Optional: Description of this channel
description: Main customer support Facebook Messenger channel for production environment

# Required: Facebook app secret
application_secret: ${FACEBOOK_APP_SECRET}

# Required: Page access token for the Facebook page
page_access_token: ${FACEBOOK_PAGE_ACCESS_TOKEN}

# Required: Verification token for webhook verification. This value can be any string value that you create.
# You must enter the same string when you complete the Webhooks configuration on the Facebook side.
verification_token: ${FACEBOOK_VERIFICATION_TOKEN}

# Optional: Use v2 chat completions for this channel (default: false)
use_v2_chat_completions: false
```

**Using Python:**

```python theme={null}
import os
from ibm_watsonx_orchestrate.agent_builder.channels import FacebookChannel
from dotenv import load_dotenv
load_dotenv()

# Define the Facebook Messenger channel configuration
channel = FacebookChannel(
    name="production_facebook_channel",
    description="Main customer support Facebook Messenger channel for production environment",
    application_secret=os.getenv("FACEBOOK_APP_SECRET"),
    verification_token=os.getenv("FACEBOOK_VERIFICATION_TOKEN"),
    page_access_token=os.getenv("FACEBOOK_PAGE_ACCESS_TOKEN"),
    use_v2_chat_completions=False,  # Optional: use v2 chat completions
)
```

### Configuration requirements

| Field | Required | Format | Description |
| - | - | - | - |
| `application_secret` | Yes | String | Facebook App Secret from the app's Basic settings |
| `page_access_token` | Yes | String | Page Access Token for the connected Facebook Page |
| `verification_token` | Yes | String | User-defined token used to verify Facebook webhook ownership |
| `use_v2_chat_completions` | No | Boolean | Use v2 chat completions for this channel. Defaults to `false`. |
