---
"@context": https://schema.org
"@type": TechArticle
"@id": https://www.twilio.com/docs/content/using-facebook-messenger-with-content-editor#article
headline: Using Facebook Messenger with Content Templates
description: Set up a Facebook Messenger (FBM) sender, add it to a Messaging Service, configure webhooks, and send Content Templates over Facebook Messenger with Twilio.
url: https://www.twilio.com/docs/content/using-facebook-messenger-with-content-editor
inLanguage: en
dateModified: 2026-09-25T14:24:38.000Z
author:
  "@type": Organization
  name: Twilio Developer Education Team
publisher:
  "@type": Organization
  name: Twilio
---

# Using Facebook Messenger with Content Templates

This guide shows you how to set up a Facebook Messenger (FBM) sender and send Content Templates over Facebook Messenger with Twilio.

## Facebook Messenger prerequisites for Content Templates

To get started with Facebook Messenger and Content Templates, you need the following:

1. A Facebook page for your business
2. A Facebook account with admin access
3. Facebook Messenger Channel integrated with the Twilio Console

For more details on the prerequisites of using Facebook Messenger with the Content API, see [Getting Started with the Facebook Messenger Channel](https://help.twilio.com/hc/en-us/articles/360018988274-Getting-Started-with-the-Facebook-Messenger-Channel-Beta-).

## Important considerations

* Twilio/location and `twilio/list-picker` do not work on FBM.
* FBM is in-session (user initiated) only. It means:

  * You can't start a conversation with a user, only respond to them.
  * Once they've messaged you, you can respond any number of times within a 24 hour period.

    * FBM is subject to FB's commerce and business policies.
    * Users can report spam, abuse, and unpleasant messages. If there is a pattern of such messages, FB will disable the page from FBM.
* Quick Reply button IDs aren't returned in the message metadata and don't work. Quick reply button text will be returned instead.

## Find your Facebook page's Messenger ID

1. Log into your Facebook Messenger Account.
2. Go to your Facebook Page.
3. Open a chat in Messenger.

   ![Messenger options menu with Twilio Tester chat open.](https://docs-resources.prod.twilio.com/81c94abd684fea90669674b97004732f9324fab69543ea1796a06ce59c9dff7d.png)
4. Note the page URL's suffix, this your page's FBM ID. (for instance, `103800709108123` in this URL). You will use this later in the configuration process.

   ![Facebook message URL in browser address bar.](https://docs-resources.prod.twilio.com/3fdbd4591f5a7d95af56283f021cdb18db3f419c8cfbb23ecb0babc415866554.png)

## Set up your FBM Sender

## Twilio Console

1. Go to the Twilio Console and navigate to **Communications > Numbers & senders > Facebook Messenger**.
2. Click **Enable Facebook Messenger** and sign in with the Facebook account that has admin access to your Facebook Page.
3. Add the Facebook Page that you want to send messages from confirming the FBM ID matches.

## Legacy Console

1. Open the legacy Console in a new browser. Click on **Explore Products** in the navigation pane and select **Channels** Beta product.
2. Navigate to the **Facebook Messenger** product.
3. Click **New Messenger Sender**, sign into the Facebook account with admin access to your Facebook Page.
4. Add the Facebook Page that you want to send messages from confirming the FBM ID matches.

> \[!WARNING]
>
> Messages sent from Facebook Business Manager won't appear in Twilio. Ensure that all messages intended for Twilio are sent directly from the Twilio platform.

## Add your FBM Sender to your Messaging Service

1. Set up a Messaging Service if you don't already have one. In the Twilio Console, go to [Messaging Services](https://1console.twilio.com/us1/develop/sms/services?frameUrl=%2Fconsole%2Fsms%2Fservices%3Fx-target-region%3Dus1\&currentFrameUrl=%2Fconsole%2Fsms%2Fservices%2Fcreate%3F__override_layout__%3Dembed%26bifrost%3Dtrue%26x-target-region%3Dus1) and click **Create a Messaging Service**. This is the same Messaging Service and sender pool to which you can add your WhatsApp and SMS/MMS senders.
2. To add a FBM Sender, navigate to the Messaging Service created previously. Go to the **Sender Pool** section and add the **Facebook Sender** that you've set up.

\*This is not a hard requirement. But if you do not do this then you will need to set up the webhook in your FBM Sender. Additionally, you will need to specify a Messaging Service Sid parameter and put your FBM sender in the from field. [Similar to here](/docs/content/using-messaging-services-with-content-templates#send-messages-with-a-phone-number-in-the-from-field) except replace phone numbers with the respective FBM sender id.

## Set up Webhooks for your Messaging Service

To send a message in FBM, you need to know your recipient's FBM ID. Facebook does not make FBM IDs public so you will need to use a webhook to retrieve the FBM ID from an inbound message. For setup purposes and testing purposes, you will need to set up a webhook and message yourself to get your personal FBM ID.

1. Navigate to Messaging Services and go to the **Integration** tab.
2. Select **Send a webhook**.
3. Add a "Request URL" where you can receive incoming messages from your end users. If you need a testing webhook, try going to webhook.site
4. Copy the webhook into the Delivery Status Callback URL section.

   ![Webhook integration settings with request and fallback URLs for HTTP Post.](https://docs-resources.prod.twilio.com/30f91dec4cfb034443145bde9033960bfd6bc7006ec07d83efc0b3f271dfc3dc.png)

## Find your Customer's FBM ID

1. Send a message to your page from your personal Facebook Messenger:

   * Log into your FBM account and click **Message** on your FBM page.
   * Send any message.
2. After sending your FB page a message with your personal FBM account. Check the webhook for the `FROM` field. This will contain the end user's FBM ID.
3. In your send request, you'll use the FBM ID found in the `From` field for the incoming message's webhook response.

Sending a Facebook Messenger Message with Content API

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID at twilio.com/console
// Provision API Keys at twilio.com/console/runtime/api-keys
// and set the environment variables. See http://twil.io/secure
// For local testing, you can use your Account SID and Auth token
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const apiKey = process.env.TWILIO_API_KEY;
const apiSecret = process.env.TWILIO_API_SECRET;
const client = twilio(apiKey, apiSecret, { accountSid: accountSid });

async function createMessage() {
  const message = await client.messages.create({
    contentSid: "HXXXXXXXXXXXXXXXX",
    contentVariables: JSON.stringify({
      1: "YOUR_VARIABLE1",
      2: "YOURVARIABLE2",
    }),
    from: "+14155552344",
    to: "messenger:REPLACE_WITH_VALUE_FROM_WEBHOOK",
  });

  console.log(message.body);
}

createMessage();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client
import json

# Find your Account SID at twilio.com/console
# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See http://twil.io/secure
# For local testing, you can use your Account SID and Auth token
api_key = os.environ["TWILIO_API_KEY"]
api_secret = os.environ["TWILIO_API_SECRET"]
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
client = Client(api_key, api_secret, account_sid)

message = client.messages.create(
    from_="+14155552344",
    content_sid="HXXXXXXXXXXXXXXXX",
    content_variables=json.dumps({"1": "YOUR_VARIABLE1", "2": "YOURVARIABLE2"}),
    to="messenger:REPLACE_WITH_VALUE_FROM_WEBHOOK",
)

print(message.body)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using System.Threading.Tasks;
using System.Collections.Generic;
using Newtonsoft.Json;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID at twilio.com/console
        // Provision API Keys at twilio.com/console/runtime/api-keys
        // and set the environment variables. See http://twil.io/secure
        // For local testing, you can use your Account SID and Auth token
        string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY");
        string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET");
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");

        TwilioClient.Init(apiKey, apiSecret, accountSid);

        var message = await MessageResource.CreateAsync(
            from: new Twilio.Types.PhoneNumber("+14155552344"),
            contentSid: "HXXXXXXXXXXXXXXXX",
            contentVariables: JsonConvert.SerializeObject(
                new Dictionary<string, Object>() {
                    { "1", "YOUR_VARIABLE1" }, { "2", "YOURVARIABLE2" }
                },
                Formatting.Indented),
            to: new Twilio.Types.PhoneNumber("messenger:REPLACE_WITH_VALUE_FROM_WEBHOOK"));

        Console.WriteLine(message.Body);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.type.PhoneNumber;
import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import org.json.JSONObject;

public class Example {
    // Find your Account SID at twilio.com/console
    // Provision API Keys at twilio.com/console/runtime/api-keys
    // and set the environment variables. See http://twil.io/secure
    // For local testing, you can use your Account SID and Auth token
    public static final String API_KEY = System.getenv("TWILIO_API_KEY");
    public static final String API_SECRET = System.getenv("TWILIO_API_SECRET");
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");

    public static void main(String[] args) {
        Twilio.init(API_KEY, API_SECRET, ACCOUNT_SID);
        Message message = Message
                              .creator(new com.twilio.type.PhoneNumber("messenger:REPLACE_WITH_VALUE_FROM_WEBHOOK"),
                                  new com.twilio.type.PhoneNumber("+14155552344"),
                                  "HXXXXXXXXXXXXXXXX")
                              .setContentVariables(new JSONObject(new HashMap<String, Object>() {
                                  {
                                      put("1", "YOUR_VARIABLE1");
                                      put("2", "YOURVARIABLE2");
                                  }
                              }).toString())
                              .create();

        System.out.println(message.getBody());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"encoding/json"
	"fmt"
	"github.com/twilio/twilio-go"
	api "github.com/twilio/twilio-go/rest/api/v2010"
	"os"
)

func main() {
	// Find your Account SID at twilio.com/console
	// Provision API Keys at twilio.com/console/runtime/api-keys
	// and set the environment variables. See http://twil.io/secure
	// For local testing, you can use your Account SID and Auth token
	accountSid := os.Getenv("TWILIO_ACCOUNT_SID")
	apiKey := os.Getenv("TWILIO_API_KEY")
	apiSecret := os.Getenv("TWILIO_API_SECRET")
	client := twilio.NewRestClientWithParams(twilio.ClientParams{
		Username:   apiKey,
		Password:   apiSecret,
		AccountSid: accountSid,
	})

	ContentVariables, ContentVariablesError := json.Marshal(map[string]interface{}{
		"1": "YOUR_VARIABLE1",
		"2": "YOURVARIABLE2",
	})

	if ContentVariablesError != nil {
		fmt.Println(ContentVariablesError)
		os.Exit(1)
	}

	params := &api.CreateMessageParams{}
	params.SetFrom("+14155552344")
	params.SetContentSid("HXXXXXXXXXXXXXXXX")
	params.SetContentVariables(string(ContentVariables))
	params.SetTo("messenger:REPLACE_WITH_VALUE_FROM_WEBHOOK")

	resp, err := client.Api.CreateMessage(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Body != nil {
			fmt.Println(*resp.Body)
		} else {
			fmt.Println(resp.Body)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID at twilio.com/console
// Provision API Keys at twilio.com/console/runtime/api-keys
// and set the environment variables. See http://twil.io/secure
// For local testing, you can use your Account SID and Auth token
$apiKey = $_ENV["TWILIO_API_KEY"];
$apiSecret = $_ENV["TWILIO_API_SECRET"];
$sid = $_ENV["TWILIO_ACCOUNT_SID"];
$twilio = new Client($apiKey, $apiSecret, $sid);

$message = $twilio->messages->create(
    "messenger:REPLACE_WITH_VALUE_FROM_WEBHOOK", // To
    [
        "from" => "+14155552344",
        "contentSid" => "HXXXXXXXXXXXXXXXX",
        "contentVariables" => json_encode([
            "1" => "YOUR_VARIABLE1",
            "2" => "YOURVARIABLE2",
        ]),
    ],
);

print $message->body;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID at twilio.com/console
# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See http://twil.io/secure
# For local testing, you can use your Account SID and Auth token
api_key = ENV['TWILIO_API_KEY']
api_secret = ENV['TWILIO_API_SECRET']
account_sid = ENV['TWILIO_ACCOUNT_SID']
@client = Twilio::REST::Client.new(api_key, api_secret, account_sid)

message = @client
          .api
          .v2010
          .messages
          .create(
            from: '+14155552344',
            content_sid: 'HXXXXXXXXXXXXXXXX',
            content_variables: {
                '1' => 'YOUR_VARIABLE1',
                '2' => 'YOURVARIABLE2'
              }.to_json,
            to: 'messenger:REPLACE_WITH_VALUE_FROM_WEBHOOK'
          )

puts message.body
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:core:messages:create \
   --from +14155552344 \
   --content-sid HXXXXXXXXXXXXXXXX \
   --content-variables {\"1\":\"YOUR_VARIABLE1\",\"2\":\"YOURVARIABLE2\"} \
   --to messenger:REPLACE_WITH_VALUE_FROM_WEBHOOK
```

```bash
CONTENT_VARIABLES_OBJ=$(cat << EOF
{
  "1": "YOUR_VARIABLE1",
  "2": "YOURVARIABLE2"
}
EOF
)
curl -X POST "https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json" \
--data-urlencode "From=+14155552344" \
--data-urlencode "ContentSid=HXXXXXXXXXXXXXXXX" \
--data-urlencode "ContentVariables=$CONTENT_VARIABLES_OBJ" \
--data-urlencode "To=messenger:REPLACE_WITH_VALUE_FROM_WEBHOOK" \
-u $TWILIO_API_KEY:$TWILIO_API_SECRET
```

```json
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXX",
  "api_version": "2010-04-01",
  "body": "Hello! 👍",
  "date_created": "Thu, 24 Aug 2023 05:01:45 +0000",
  "date_sent": "Thu, 24 Aug 2023 05:01:45 +0000",
  "date_updated": "Thu, 24 Aug 2023 05:01:45 +0000",
  "direction": "outbound-api",
  "error_code": null,
  "error_message": null,
  "from": "+14155552344",
  "num_media": "0",
  "num_segments": "1",
  "price": null,
  "price_unit": null,
  "messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "status": "queued",
  "subresource_uris": {
    "media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json"
  },
  "to": "messenger:REPLACE_WITH_VALUE_FROM_WEBHOOK",
  "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
}
```
