Facebook Messenger for Flex is currently available as a Public Beta product and the information contained in this document is subject to change. This means that some features are not yet implemented and others may be changed before the product is declared as Generally Available. Public Beta products are not covered by a Twilio SLA.
Not a HIPAA Eligible Service
Facebook Messenger for Flex is not a HIPAA Eligible Service and cannot be used in Flex workflows that are subject to HIPAA.
This guide describes how to set up Facebook Messenger as a Flex Conversations channel. Once configured, agents in Flex can receive and reply to messages that come from Facebook Pages. Customers must message agents first, as agent-initiated outbound messages are not supported. For more details, see Facebook's messaging policy. Messages can include text, images, and file attachments.
Some benefits of using Facebook Messenger with Flex include:
For limitations, see File Attachments and API Limits and Known Issues.
For more detailed information on setup and functionality, see Facebook Messenger Setup.
To receive and reply to messages in Flex, create a Conversations address through the Console or using the API.
From the Address Type list, select Facebook Messenger.
You can programmatically create and manage a Messenger address using the Conversations API's Address Configuration Resource. The example below includes a retry count:
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createConfigurationAddress() {11const addressConfiguration =12await client.conversations.v1.addressConfigurations.create({13address: "messenger:<facebook_page_id>",14"autoCreation.enabled": true,15"autoCreation.studioFlowSid": "FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",16"autoCreation.studioRetryCount": 3,17"autoCreation.type": "studio",18type: "messenger",19});2021console.log(addressConfiguration.sid);22}2324createConfigurationAddress();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"sid": "IGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"address": "messenger:<facebook_page_id>",5"type": "messenger",6"friendly_name": "My Test Configuration",7"address_country": "CA",8"auto_creation": {9"enabled": true,10"type": "webhook",11"conversation_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",12"webhook_url": "https://example.com",13"webhook_method": "POST",14"webhook_filters": [15"onParticipantAdded",16"onMessageAdded"17]18},19"date_created": "2016-03-24T21:05:50Z",20"date_updated": "2016-03-24T21:05:50Z",21"url": "https://conversations.twilio.com/v1/Configuration/Addresses/IGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"22}