Getting Started with the Facebook Messenger Channel (Beta)

Twilio now supports sending and receiving messages to and from Facebook Messenger users! The Facebook Messenger channel helps expand your reach and availability to your important contacts on any platform that is convenient for them. Best of all, Facebook messages are controlled by Twilio's existing Programmable SMS API. Here's what you need to know to get started.

Notice: The Facebook Messenger Channel is currently in beta, and has not yet been finalized. Support requests for beta and pre-release products are generally handled by our engineering team, and as such, response times are not guaranteed. For more information on Support limitations for beta and pre-release products, please see Twilio Beta Product Support.

Facebook Messaging Capabilities

Facebook users will need to initiate contact with you by messaging your Facebook page before you are able to contact them. Once a user’s message is received, Twilio can respond back to the user for 24 hours. One additional message is allowed after the 24-hour window has expired.

For more details, please see Facebook’s Messenger Platform Policy Overview (Facebook for Developers).

Setup Process

Here are the steps required to setup the Facebook Messenger Channel:

  1. Create a Facebook Page.
  2. Create your Twilio app for routing Facebook messages.
  3. Install and Configure the Facebook Messenger Channel.

Step 1: Creating a Facebook Page

In the Facebook Messenger ecosystem, users communicate with brands and companies by messaging their Facebook Page. Similarly, the Facebook Messenger Channel requires a Facebook Page for connecting, rather than just a personal account.

To create a Facebook Page, login to your Facebook account, click Pages, and then create a new page.

Step 2: Create your Twilio App for Routing Facebook Messages

Incoming messages will hit your Twilio application with the same request parameters as a standard Twilio SMS message. But, because of the sender and recipient are Messenger:xxxxx, simple TwiML replies won't work. All outbound messages will need to be sent through Twilio via an API Request. 

To send a Facebook message, your application needs to make an HTTP POST request to Twilio’s Programmable SMS Message REST API resource with three required pieces of information; A recipient, a sender, and your message.

  • Recipient: The To parameter consisting of messenger: followed by the Facebook Messenger User ID from the message you're replying to.
  • Sender: The From parameter consisting of messenger: followed by your Facebook Page ID.
  • Message: The Body parameter consisting of the desired response you wish to send.

Here’s an example cURL script:

curl -X POST \
--data-urlencode "To=messenger:{Messenger_User_ID}" \
--data-urlencode "From=messenger:{Facebook_Page_ID}" \
--data-urlencode "Body=Thank you for your message." \

This example will send a response to the Facebook user at messenger:{Messenger_User_ID) from your Facebook Page ID with the following body:

Thank you for your message.

To make this script work for you, make the following updates, and then paste it into a terminal window:

  • Line 1 update with your Account SID
  • Line 2 update with the incoming Facebook Messenger User ID you're replying to
  • Line 3 update your Facebook Page ID
  • Line 4 update with your desired message
  • Line 5 update with your Account SID and Auth Token.

For more details, including code samples from our Helper Libraries, please see Sending Messages (Twilio Docs).

Step 3: Install and Configure the Facebook Messenger Channel

To begin sending and receiving Twilio messages with Facebook Messenger, you’ll need to start by installing and setting up the Facebook Messenger Channel. Here are the instructions to get you setup:

  1. Login to your project at
  2. Click Channels from the left-side navigation bar.
    NOTE: If Channels is not visible, click All Products & Services.
  3. Click Facebook Messenger.
  4. Click Install.
  5. Review the Facebook terms of service. If you wish to continue, check the “I agree…” box, and then click Agree & Install.
  6. From the “Configure” tab, click the Facebook Log In button, and then follow the prompts.
  7. Once logged in, make the following changes, and then click Save.
    Properties INSTALLED CHANNEL SID (Auto populates when once page selected)
      INBOUND CHANNEL URL (Auto populates when once page selected)
      UNIQUE NAME Edit as desired.
      USE IN Select the product(s) you intend to use.
    Credentials FACEBOOK LOGIN Click Log In, and then follow the prompts.
      SELECT A PAGE Select your Facebook Page from Step 1.
    Configuration PAGE ID (Auto populates when once page selected)
      PAGE FRIENDLY NAME (Auto populates when once page selected)
      CALLBACK URL Enter your Twilio App URL from Step 2.
      FALLBACK URL (OPTIONAL) Enter a backup Twilio App URL.
      STATUS CALLBACK URL (OPTIONAL) Enter your Callback URL.

Additional Resources

Have more questions? Submit a request
Powered by Zendesk