Facebook Messenger
Our business messaging API supports sending and receiving Facebook Messenger messages.
Being able to send Facebook Messenger messages requires requesting access via the Channels portal. Without onboarding with Facebook Messenger via the portal, you can not make use of this part of the API.
Fact sheet
Feature | Support | Remarks |
---|---|---|
delivery notification | yes | Occurs when your message is delivered to the Facebook Messenger platform. Delivery notifications are sent to the status report webhooks. |
text messages | yes | The maximum length of a Facebook Messenger message is 2.000 characters and it must be UTF-8 encoded. |
media | yes | Media name attribute should end in the proper file extension. Only one media file is allowed per message; when sending multiple files, each file will be sent in its own Facebook Messenger message. When the linked media doesn't exist/can't be found, the message will not be sent at all. The provided text message is sent in a separate Facebook Messenger message. |
media: images | yes | Maximum file size for an uploaded image is 25 MB. Supported formats: png, jpeg, gif. |
media: gifs | yes | |
media: video | yes | Maximum file size for an uploaded video is 25 MB. Supported formats: mp4, ogg, avi, mov, webm. |
media: audio | yes | Maximum file size for an uploaded audio is 25 MB. Supported formats: acc, m4a, wav, mp4. |
media: document | yes | Maximum file size for an uploaded document is 25 MB. All common MIME types supported. For example: application/pdf. |
reply suggestions | yes | Maximum label length: 20 characters. |
rich card | yes | Support for generic, media, button and product template. |
rich carousel | yes | Support for generic and product templates. Maximum of 10 templates supported. |
message tags | yes | Allows messaging outside the standard messaging window of 24 hours. |
marketing messages: optin requests | yes | Support for sending marketing message optin requests. |
marketing messages: notifications | yes | Support for sending all message types as marketing message. |
Onboarding
Onboarding is done via our Channels portal. On our portal, you will be presented with a Facebook login pop up. In this pop up you will need to authorize our Facebook app, called CM.com Business Messaging to send and receive Facebook Messenger messages on behalf of your Facebook account.
This app requires the following permissions to work correctly:
- "Manage and access Page conversations in Messenger"
- "Show a list of the Pages you manage"
If you choose the de-select these permissions in the Facebook pop up, we will not be able to complete the onboarding.
Business rules
Sending Facebook Messenger messages using the CM Business Messaging API also requires you to adhere to the Facebook Messenger Policy & Guidelines.
It is allowed to have multiple Facebook accounts under one CM.com account.
Considerations
Note that in case of Facebook, the Facebook account that is used for sending messages is also still available in the regular Facebook app, from the Facebook website and from other 3rd party Facebook apps. Our API only has permissions to send on behalf of the Facebook account, but it's not exclusively in control of that Facebook account.
This means that it will be possible to send messages using Facebook as well as using our API, and that might lead to situations where the API will relay replies to messages you sent via the Facebook app or website.
In those cases it will seem like messages are missing from a conversation when you use both ways of communicating with your end-users.
Our recommendation is to use the API exclusively for these Facebook accounts, and not switch between the Facebook app or website and the API, because the API won't "know" about the messages you sent using the app or website, but it will receive the replies to those messages.
The only way to have a Facebook Messenger conversation with end-users is when the end-user starts the conversation by sending you an initial message.
Facebook Messenger has rate limits in place; the hourly rate limit is equal to 200 * the number of people the customer can message via Facebook Messenger. This limit is high enough for most use cases. So if you have 1 conversation with 1 customer you can sent maximum 200 messages back to this customer. If there are 2 conversations with 2 customer you can sent maximum 400 messages back to these customers.
If you choose to revoke any of the permissions given during the onboarding process on Facebooks side, we might no longer be able to deliver messages.
Once onboarded, the authorization of our Facebook app expires after 90 days. This impacts the ability of our Facebook app to retrieve the name of the end user. In order to remedy this, you must re-authorize our Facebook app using the same onboarding process.
Sending messages
Unlike other channels, Facebook Messenger does not use telephone numbers as identifiers for sender (from
) and recipient (to.number
), instead it uses a so called "Page Scoped User ID (PSID)" for the recipient and a "Page ID" for the sender. A person is assigned a unique PSID for each Facebook Page they start a conversation with. Do note that the PSID is only valid for the Facebook page that received a message from a Facebook user.
Your Page ID is visible in the CM.com platform under channels...Facebook Messenger
. The last section of the Page URL is your Page ID. E.g. https://www.facebook.com/1234567890 with 1234567890 as the Page ID.
Input matrix
You can use the following matrix to check what type of message will be send with the included inputs.
Text | Media | Suggestions | Header | Output |
---|---|---|---|---|
x | x | x | x | Not supported |
x | x | x | √ | Generic template |
x | x | √ | x | Product template if 'ViewProduct' action, otherwise not supported |
x | x | √ | √ | Button template with max 3 buttons or as template with quick replies |
x | √ | x | x | Media message |
x | √ | x | √ | Generic template |
x | √ | √ | x | Media template with max 1 button or as template with quick replies |
x | √ | √ | √ | Generic template with max 3 buttons or as template with quick replies |
√ | x | x | x | Text message |
√ | x | x | √ | Generic template |
√ | x | √ | x | Text message with quick replies |
√ | x | √ | √ | Generic template with max 3 buttons or as template with quick replies |
√ | √ | x | x | Text and Media messages |
√ | √ | x | √ | Generic template |
√ | √ | √ | x | Not supported |
√ | √ | √ | √ | Generic template with max 3 buttons or as template with quick replies |
Text
Direct message with plain text content
The example below will send a simple text-only Facebook Messenger message.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your Page ID",
"to": [
{
"number": "Recipients PSID"
}
],
"allowedChannels": ["Facebook Messenger"],
"body": {
"type": "auto",
"content": "CM.com - Be part of it."
}
}
]
}
}
Media
Media type | Supported formats | Mimetype | Supported size maximum |
---|---|---|---|
Audio | acc, m4a, wav, mp4 | audio/acc, audio/m4a, audio/wav, audio/mp4 | 25MB |
Image | png, jpeg, gif | image/png, image/jpeg, image/gif | 8MB |
Video | mp4, ogg, avi, mov, webm | video/mp4, video/ogg, video/avi, video/mov, video/webm | 25MB |
Document | application/pdf | All common MIME types supported. For example: application/pdf | 25MB |
Display order
If you send a message including both an image and some text, Facebook Messenger will display these as separate messages; typically the text will be the first message.
Direct message with text and image
In the example below, we send a simple rich content message that contains both text and an image that Facebook Messenger will display as two separate messages.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your Page ID",
"to": [
{
"number": "Recipients PSID"
}
],
"body": {
"type": "auto",
"content": "Fallback Text"
},
"allowedChannels": ["Facebook Messenger"],
"richContent": {
"conversation": [
{
"text": "CM.com - Be part of it.",
"media": {
"mediaName": "cm.png",
"mediaUri": "https://www.cm.com/cdn/cm/cm.png",
"mimeType": "image/png"
}
}
]
}
}
]
}
}
Direct message with text and video
In the example below, we send a simple rich content message that contains both text and a video that Facebook Messenger will display as two separate messages.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your Page ID",
"to": [
{
"number": "Recipients PSID"
}
],
"body": {
"type": "auto",
"content": "Fallback Text"
},
"allowedChannels": ["Facebook Messenger"],
"richContent": {
"conversation": [
{
"text": "CM.com - Be part of it.",
"media": {
"mediaName": "your-video.mp4",
"mediaUri": "your-video-url.mp4",
"mimeType": "video/mp4"
}
}
]
}
}
]
}
}
Direct message with text and document
In the example below, we send a simple rich content message that contains both text and a document that Facebook Messenger will display as two separate messages.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your Page ID",
"to": [
{
"number": "Recipients PSID"
}
],
"body": {
"type": "auto",
"content": "Fallback Text"
},
"allowedChannels": ["Facebook Messenger"],
"richContent": {
"conversation": [
{
"text": "CM.com - Be part of it.",
"media": {
"mediaName": "cm-pdf.pdf",
"mediaUri": "your-document.pdf",
"mimeType": "application/pdf"
}
}
]
}
}
]
}
}
Direct message with text and audio
In the example below we send a simple rich content message that contains both text and audio that Facebook will display as two separate messages.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your Page ID",
"to": [
{
"number": "Recipients PSID"
}
],
"body": {
"type": "auto",
"content": "Fallback Text"
},
"allowedChannels": ["Facebook Messenger"],
"richContent": {
"conversation": [
{
"text": "CM.com - Be part of it.",
"media": {
"mediaName": "your-audio.mp4",
"mediaUri": "your-audio-url.mp4",
"mimeType": "audio/mp4"
}
}
]
}
}
]
}
}
Suggestions (Quick Reply)
The following actions are supported by Facebook as buttons.
Action | Remarks |
---|---|
Reply* | Maximum length of label is 20 characters. |
OpenUrl | Maximum length of label is 20 characters, url required. |
Dial | Maximum length of label is 20 characters, phone number required. |
Login | Suggestion without text, url required. |
Logout | Suggestion without text. |
Note
A reply action can be used as either a button or as a quick reply.
An explanation on suggestions can be found under Suggestions/Features
Quick reply
Quick Replies allows you to suggest quick answers for the recipient beneath your message.
Quick replies can be combined with any type of message; text, media or rich card.
A maximum of 13 quick replies are supported by Facebook Messenger.
The following restrictions apply for a quick reply:
Field | Required | Remarks |
---|---|---|
label | Yes | Maximum length is 20 characters. |
postbackdata | Yes | Maximum length is 1000 characters. |
media | No | Thumbnail image, should be at least 24 x 24 pixels. |
Quick replies can also be included as a reply button to a template but each template has its own button limit.
If those limit has been passed, your reply suggestions will be included as quick replies beneath your message.
Direct message with quick reply suggestions
In the example below we send a rich content message that contains a text and some reply suggestions.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your Page ID",
"to": [
{
"number": "Recipients PSID"
}
],
"body": {
"content": ""
},
"allowedChannels": ["Facebook Messenger"],
"richContent": {
"conversation": [
{
"text": "Hi, what can I do for you?",
"suggestions": [
{
"action": "Reply",
"label": "Call me",
"postbackdata": "CALL"
},
{
"action": "Reply",
"label": "Email me",
"postbackdata": "EMAIL"
},
{
"action": "Reply",
"label": "Send me an sms",
"postbackdata": "SMS"
}
]
}
]
}
}
]
}
}
Message Tags
Message tags enable sending important and personally relevant 1:1 updates to users outside the standard messaging window of 24 hours. This enables greater flexibility in how you interact with people, as well as the types of experiences you can build on the Facebook Messenger Platform. They may not be used to send promotional content (e.g. deals, offers, coupons, discounts, etc.). Use of tags outside of the approved use cases may result in restrictions on the Page's ability to send messages. See the Facebook Messenger Platform policy for details.
The following message tags are supported:
Tag | Description |
---|---|
CONFIRMED_EVENT_UPDATE | Send the user reminders or updates for an event they have registered for (e.g., RSVP'ed, purchased tickets). This tag may be used for upcoming events and events in progress. |
POST_PURCHASE_UPDATE | Notify the user of an update on a recent purchase. |
ACCOUNT_UPDATE | Notify the user of a non-recurring change to their application or account. |
HUMAN_AGENT | Allows human agents to respond to user inquiries. Messages can be sent within 7 days after a user message. |
NOTIFICATION_MESSAGE | Allows to send all message types as a marketing message, needs to be combined with a notification_token as recipient. |
Direct message with message tag
In the example below we send a simple text message with a message tag "POST_PURCHASE_UPDATE" applied. This tag is used to notify the user of an update on a recent purchase.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your Page ID",
"to": [
{
"number": "Recipients PSID"
}
],
"body": {
"type": "auto",
"content": "Fallback Text"
},
"allowedChannels": ["Facebook Messenger"],
"richContent": {
"conversation": [
{
"text": "Dear customer, your order with id 1234xyz has been shipped.",
"tag": "POST_PURCHASE_UPDATE"
}
]
}
}
]
}
}
Rich card
Rich cards, called templates in Facebook Messenger, offer a way for you to offer a richer in-conversation experience than standard text messages by integrating buttons, images and more alongside text in a single message. Rich cards can be used for many purposes, such as displaying product information or asking the message recipient to choose from a pre-determined set of options.
You can send rich cards as one of the following Facebook templates.
- Button template
- Media template
- Product template
- Generic template
More info about the templates specifically down below.
When sending rich cards we recommend adhering to the Best Practices defined by Facebook.
Button template
The button template sends a structured message with up to three attached buttons.
This template is useful for offering the recipient options to choose from, such as pre-determined responses to a question, or actions to take.
The button template is quit similar to other templates. But unlike other templates, there is a maximum of 640 characters.
The following restrictions apply for a button template:
Field | Support | Required | Remarks |
---|---|---|---|
cards | No | No | Supported if a single card is given |
header | Yes | Yes | Displayed as the text. Maximum length is 640 characters. |
text | No | No | - |
mediaUri | No | No | - |
suggestions | Yes | Yes | Maximum of 3 buttons per card. If more are given, all will be included as quick replies, instead of buttons. |
The following Facebook buttons can be used. More info about each button can be found in the rich content description.
Button | Action | Remarks |
---|---|---|
URL | OpenUrl | Maximum length of button text is 20 characters, url required. |
Postback | Reply | Maximum length of button text is 20 characters. |
Call number | Dial | Maximum length of button text is 20 characters, phone number required. |
Log in | Login | Button without text, url required. |
Log out | Logout | Button without text. |
When sending rich cards containing buttons, we recommend adhering the Best Practises for using buttons defined by Facebook.
Direct message with button rich card
In the example below we send a simple rich content message that contains elements that Facebook Messenger will display as a button template.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your Page ID",
"to": [
{
"number": "Recipients PSID"
}
],
"body": {
"type": "auto",
"content": "Fallback Text"
},
"allowedChannels": ["Facebook Messenger"],
"richContent": {
"conversation": [
{
"carousel": {
"cards": [
{
"header": "CM.com - Be part of it.",
"suggestions": [
{
"action": "REPLY",
"label": "Give me more info",
"postbackdata": "INFO"
},
{
"action": "OPENURL",
"label": "Visit CM.com",
"url": "https://www.cm.com/"
}
]
}
]
}
}
]
}
}
]
}
}
Media template
The media template allows you to send a image, GIF, or video as a structured message with an optional button.
Videos and animated GIFs sent with the media template are playable in the conversation.
The following restrictions apply for a media template:
Field | Support | Required | Remarks |
---|---|---|---|
cards | No | No | Supported if a single card is given |
header | No | No | - |
text | No | No | - |
mediaUri | Yes | Yes | Image or video |
suggestions | Yes | No | Maximum of 1 button per card. If more are given, all will be included as quick replies, instead of buttons. |
Direct message with media rich card
In the example below we send a simple rich content message that contains elements that Facebook Messenger will display as a media template.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your Page ID",
"to": [
{
"number": "Recipients PSID"
}
],
"body": {
"type": "auto",
"content": "Fallback Text"
},
"allowedChannels": ["Facebook Messenger"],
"richContent": {
"conversation": [
{
"carousel": {
"cards": [
{
"media": {
"mediaName": "cm.png",
"mediaUri": "https://www.cm.com/cdn/cm/cm.png",
"mimeType": "image/png"
},
"suggestions": [
{
"action": "REPLY",
"label": "Give me more info",
"postbackdata": "INFO"
}
]
}
]
}
}
]
}
}
]
}
}
Product template
Note
This feature is in beta and not publicly available yet
The product template sends a structured message to render products that have been uploaded to your Facebook catalog.
You need to provide the product ids that are linked to your Facebook page.
Up to 10 products can be provided via either suggestions directly or suggestions in a carousel.
The following restrictions apply for a product template:
Field | Support | Required | Remarks |
---|---|---|---|
cards | Yes | No | With a maximum of 10 per message. |
header | No | No | - |
text | No | No | - |
mediaUri | No | No | - |
suggestions | Yes | Yes | Only action 'ViewProduct' supported. With a maximum of 10 per message. |
Direct message with product suggestions
In the example below we send a rich content message that contains elements that Facebook Messenger will render as a product from your product catalog.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your Page ID",
"to": [
{
"number": "Recipients PSID"
}
],
"body": {
"content": ""
},
"allowedChannels": ["Facebook Messenger"],
"richContent": {
"conversation": [
{
"suggestions": [
{
"action": "VIEWPRODUCT",
"product": {
"id": "FB_tshirt_001"
}
},
{
"action": "VIEWPRODUCT",
"product": {
"id": "FB_tshirt_002"
}
},
{
"action": "VIEWPRODUCT",
"product": {
"id": "FB_tshirt_003"
}
}
]
}
]
}
}
]
}
}
Generic template
A simple structured message that includes a title. May include a subtitle, image and up to three buttons.
This template will be used if fields are given that are not covered by other Facebook templates.
The following restrictions apply for a generic template:
Field | Support | Required | Remarks |
---|---|---|---|
cards | Yes | Yes (If header not defined) | Maximum 10 allowed per message. At least one property must be set in addition to header. |
header | Yes | Yes (If cards not defined) | Displayed as the title. Maximum length is 80 characters. |
text | Yes | No | Displayed as the subtitle. Maximum length is 80 characters. |
mediaUri | Yes | No | The URL of the image to display. |
suggestions | Yes | No | Maximum of 3 buttons per card. If more are given, all will be included as quick replies, instead of buttons. |
Direct message with rich card content with button suggestions
In the example below we send a simple rich content message that contains elements that Facebook Messenger will display as a generic template.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your Page ID",
"to": [
{
"number": "Recipients PSID"
}
],
"body": {
"type": "auto",
"content": "Fallback Text"
},
"allowedChannels": ["Facebook Messenger"],
"richContent": {
"conversation": [
{
"carousel": {
"cards": [
{
"header": "CM.com - Be part of it.",
"text": "Want to know more about CM.com?",
"media": {
"mediaName": "cm.png",
"mediaUri": "https://www.cm.com/cdn/cm/cm.png",
"mimeType": "image/png"
},
"suggestions": [
{
"action": "REPLY",
"label": "Give me more info",
"postbackdata": "INFO"
},
{
"action": "OPENURL",
"label": "Visit CM.com",
"url": "https://www.cm.com/"
}
]
}
]
}
}
]
}
}
]
}
}
Rich Card Carousel
A carousel of Rich Cards with different compositions of a title, a subtitle, a media image and multiple suggestions
In the example below we send a rich content message that contains a carousel of rich cards. The rich cards have multiple different compositions in which they are shown to the end user. It's possible to mix different elements with each other.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your Page ID",
"to": [
{
"number": "Recipients PSID"
}
],
"body": {
"type": "auto",
"content": "Fallback Text"
},
"allowedChannels": [
"Facebook Messenger"
],
"richContent": {
"conversation": [
{
"carousel": {
"cards": [
{
"header": "CM.com - Be part of it.",
"text": "Want to know more about CM.com?",
"media": {
"mediaName": "cm.png",
"mediaUri": "https://www.cm.com/cdn/cm/cm.png",
"mimeType": "image/png"
},
"suggestions": [
{
"action": "REPLY",
"label": "Give me more info",
"postbackdata": "INFO"
},
{
"action": "OPENURL",
"label": "Visit CM.com",
"url": "https://www.cm.com/"
}
]
},
{
"header": "Our logo!",
"media": {
"mediaName": "cm.png",
"mediaUri": "https://www.cm.com/cdn/cm/cm.png",
"mimeType": "image/png"
}
}
]
}
}
]
}
}
]
}
}
Marketing Messages
With Marketing Messages you can send (recurring) notifications on a topic, a user has opted-in to. During the 24-hour messaging window, you can send users this notification opt-in request. Users can opt-in to receive Marketing Messages any time after this opt-in request is sent. Once a user opts-in, you are allowed to send Marketing Messages related to the topic they opted-in to for a daily frequency.
Best practices
- Your opt-in request, including the title and image, encompasses the types of Marketing Messages users can expect to receive, such as order updates, product recommendations, or certain offers.
- When sending more than one opt-in request to a user, each opt-in request should clearly state the different, specific types of Marketing Messages the user can expect to receive.
- You must not use Marketing Messages, including opt-in requests, to spam users. This includes sending duplicate opt-in requests at high frequencies to the same users.
Users can provide feedback on your messaging experience, including blocking your messaging, which may result in restrictions on your use of Marketing Messages. You should regularly review your opt-in requests and Marketing Messages to see if they meet the best practices above.
Limitations
- You can only send one opt in request to a person per week for the same, specific topic.
- You may only send a request for a user to opt-in to Marketing Messages within the standard 24 hour messaging window. A user’s action of opting-in to Marketing Messages does not open the 24 hour messaging window.
- Do not send duplicate opt-in requests to users, which is defined as having the same title and image_url.
- You can only see if a person has opted in to receiving Marketing Messages.
- If a person has chosen to stop receiving Marketing Messages, your notifications will no longer be delivered to that person and you will receive an error.
- A person can block, mute, or report your messaging.
Sending Marketing Messages Opt-In Requests
Token Expiration and Re-Opt In
Beginning August 10, 2023, notification tokens will no longer expire. Re-opt in requests and opt out reminders will also no longer be sent.
Before sending Marketing Messages, users must opt-in via an opt-in request. You must not send more than one opt-in request to a user per week on the same, specific topic. If you attempt to send an opt-in request to a user for the same topic in less than a week, the request will be blocked and you will receive an error message. In addition, there must be an open 24 hour messaging window before you can send an opt-in request to the user. Users can opt-in to receive Marketing Messages for multiple topics in the same thread. When a user chooses to opt-in on your Marketing Message a opt-in event will be triggered, see incoming events for more information on Facebook Marketing Messages events.
You can send an opt-in request as a single suggestion. The following restrictions apply for an opt-in message:
Field | Required | Remarks |
---|---|---|
action | Yes | The action field is required and always needs to have the value "optin" to send the message as a opt-in message. |
postbackdata | Yes | Your opt-in reference. |
label | Yes | Displayed as the title. Maximum lenght is 65 characters. |
mediaUri | No | The URL of the image to display in the opt-in request. |
optin | Yes | See table below for opt-in details. |
The following fields can be included as part of opt-in:
Field | Required | Remarks |
---|---|---|
frequency | Yes | DAILY |
reoptin | No | True or False. When value is True, an automatic reoptin is sent to end-user when subscription expires. |
timezone | No | Default value is UTC. List of available time zones |
Marketing Message opt-in request
In the example below we send a Marketing Message opt-in request that gives the recipient the option to opt-in on your notifications.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"allowedChannels": ["Facebook Messenger"],
"from": "Your Facebook account ID",
"to": [
{
"number": "Recipients PSID"
}
],
"body": {
"content": ""
},
"richContent": {
"conversation": [
{
"suggestions": [
{
"action": "optin",
"postbackdata": "OPT_IN",
"label": "Nice products!",
"media": {
"mediaName": "cm.png",
"mediaUri": "https://www.cm.com/cdn/cm/cm.png",
"mimeType": "image/png"
},
"optin": {
"frequency": "DAILY",
"reoptin": true,
"timezone": "Europe/Amsterdam"
}
}
]
}
]
}
}
]
}
}
Sending Marketing Messages
After a user opt-in, you can send your users Marketing Messages once every calendar day which starts from 12:00am until 11:59pm in the time zone set by you.
Important
A Marketing Messages message token is generated per opt-in (per user) which can then be used to send Marketing Messages. This means that instead of the users PSID you need to use the specific notification token received when the user opted-into your opt-in request to send Marketing Messages to this user.
If you sent two opt-in requests (with different topics) to your user, two separate notification message tokens are generated if the user opted-in to both requests.
The NOTIFICATION_TAG
You can sent any type of Facebook message as a Marketing Message (except a opt-in request) as long as you use the notification token linked to the user as the recipient in combination with the "NOTIFICATION_MESSAGE" tag.
Sending Marketing Messages
In the example below we send a text message as a Marketing Message. Reminder: Every message type can be used as a Marketing Message as long as you combine the notification token with the "NOTIFICATION_MESSAGE" tag.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your Facebook account ID",
"to": [
{
"number": "The notification token of the user"
}
],
"body": {
"content": ""
},
"allowedChannels": ["Facebook Messenger"],
"richContent": {
"conversation": [
{
"text": "CM.com - Be part of it.",
"tag": "NOTIFICATION_MESSAGE"
}
]
}
}
]
}
}
Receiving messages / Inbound flow
Since Facebook Messenger is used for 2-way communication (chat) it is important to also implement an Inbound flow. You can find more information about how to do this using our API documentation of the Inbound webhook. Note that for Facebook Messenger you need to set up your webhook API in the Channels app, not in the Gateway app.
Updated 7 months ago