The Messenger Platform's customer chat plugin allows you to integrate your Messenger experience directly into your website. This allows your customers to interact with your business anytime with the same personalized, rich-media experience they get in Messenger.
The customer chat plugin automatically loads recent chat history between the person and your business, meaning recent interactions with your business on messenger.com, in the Messenger app, or in the customer chat plugin on your website will be visible. This helps create a single experience for your customers, and enables you to continue the conversation even after they have left your webpage. No need to capture their information to follow up, just use the same conversation in Messenger.
The customer chat plugin is supported for desktop and mobile with the following exceptions where it is not supported: - Internet Explorer - Messenger in-app browsers
Currently, the customer chat plugin supports the follow message types and structured message templates:
Feature | Supported |
---|---|
Text Message | Yes |
Video/Image/Audio/GIF | Yes (Receive Only) |
Generic/Button Template | Yes (Supported for limited button types) Postback URL Button Call Button ![]() Buy Button ![]() Share Button ![]() Log In Button ![]() Log Out Button ![]() Game Play Button |
List/Media/Open Graph Template | No |
Quick Replies | Yes (Supported for limited quick reply types) Text Quick Reply User Phone Number Quick Reply User Email Quick Reply ![]() Location Quick Reply |
Persistent Menu | Yes |
To take advantage of internationalization, including automatic language translation, you need to change the locale of the SDK to match the locale of your site. Specifically, you need to change en_US to a supported locale code when loading the SDK's source.
For more information, see Localization with Social Plugins and JavaScript SDK.
By default, the plugin will be shown on desktop and minimized on mobile. Users can also click to show or minimize the plugin. This state is cached on the browser for the duration of the page session (including page reloads).
To use the customer chat plugin, you must include the Facebook JavaScript SDK in the page where the plugin will be rendered.
For instructions on including the SDK, see Facebook JavaScript SDK Quickstart.
To include the customer chat plugin on your webpage, do the following:
Domains must meet the following requirements to be whitelisted:
Served over HTTPS
Use a fully qualified domain name, such as https://www.messenger.com/. IP addresses and localhost are not supported for whitelisting.
For security reasons, the plugin will only render when loaded on a domain that you have whitelisted. Refer to whitelisted_domains
reference to learn how to whitelist your domain programmatically.
Businesses whose Messenger experience is provided by a service provider, will not have access to the page token generator in app settings because they do not own the Facebook app. In this case, you may add or remove whitelisted domains via Page settings. To whitelist a domain, do the following:
We highly suggest not changing the default position of the customer chat plugin from the bottom-right corner of your page.
div
with the following attributes in your HTML:
<div class="fb-customerchat"
page_id="<PAGE_ID>"
ref="<OPTIONAL_WEBHOOK_PARAM>"
theme_color="<HEX_COLOR_CODE>"
logged_in_greeting="<GREETING_MESSAGE_FOR_LOGGED_IN_USERS>"
logged_out_greeting="<GREETING_MESSAGE_FOR_LOGGED_OUT_USERS>">
</div>
By default, the greeting dialog will be shown on desktop and be hidden on mobile. To customize the behavior, you can use the greeting_disalog_dislay
attribute to further customize your plugin.
For a complete list of attributes, see the Customer Chat Plugin reference.
messaging_postbacks
event for new conversationsIf a new conversation is started via the plugin, and your bot has set up the get started button, we will send a messaging_postbacks
webhook event to your webhook when the user clicks the get started button.
If the ref
attribute is set in the include for the customer chat plugin, it will be included in the postback event.
messaging_referrals
event for existing conversationsFor existing conversations, if the ref
attribute is set in the include for the customer chat plugin, a messaging_referrals
webhook event will be sent to your webhook when the conversation is continued via the plugin.
The ref
can be any string and can be used for a variety of purposes. For example, you could use it to keep track of which customers have engaged with your business via the plugin.
The customer chat plugin supports the following customizations. All customizations are set as an attribute when the plugin is included on your webpage:
Attribute | Description |
---|---|
| Optional. The color to use as a theme for the plugin, including the background color of the customer chat plugin icon and the background color of any messages sent by users. Supports any hexidecimal color code with a leading number sign (e.g. #0084FF), except white. We highly recommend you choose a color that has a high contrast to white. |
| Optional. The greeting text that will be displayed if the user is currently logged in to Facebook. Maximum 80 characters. |
| Optional. The greeting text that will be displayed if the user is currently not logged in to Facebook. Maximum 80 characters. |
| Optional. Sets how the greeting dialog will be displayed. The following values are supported:
Defaults to |
| Optional. Sets the number of seconds of delay before the greeting dialog is shown after the plugin is loaded. This can be used to customize when you want the greeting dialog to appear. |
| Deprecation NoticeThis attribute is now deprecated. Please use Optional.
|
For Page Admins, the Messenger Platform also provides an easy setup tool for customizing your customer chat plugin. To use the setup tool, do the following:
The setup tool provides a simple UI for customizing the greeting message, theme color, displayed response time, and setting the whitelisted domains for the plugin.
On completion, the setup tool automatically generates the code snippets that you can copy/paste to include the customer chat plugin in your webpage.
There may be cases where it is preferable to disable the persistent menu for your bot in the customer chat plugin. To do this, add "disabled_surfaces": ["CUSTOMER_CHAT_PLUGIN"]
when you set your persistent menu:
{
"persistent_menu":[
{
"locale":"default",
"disabled_surfaces": ["CUSTOMER_CHAT_PLUGIN"],
"composer_input_disabled": false,
"call_to_actions":[
{
"title":"My Account",
"type":"postback",
"payload":"PAYBILL_PAYLOAD"
}
]
}
]
}
If your Page has country restrictions set in Page settings, the customer chat plugin will not render for users who are not logged into their Facebook account when they visit your website.
If the user is already logged in to their Facebook account, they will be able to start chatting with your bot right away. If they are not logged in, a default welcome message will be display, and they will be prompted to log in or create a new Facebook account.
At times, it may be necessary to determine whether a message was sent from the customer chat plugin. To enable this, the Messenger Platform will include a "source": "customer_chat_plugin"
property in the tags
array of the message payload for all messages sent from the plugin:
"message": {
"mid":"mid.14577641449818:41d102a3e1ae206a38",
"text":"hello, from customer chat!",
"tags": [
{
"source": "customer_chat_plugin"
}
]
}
If you're having trouble getting the plugin to render properly, try the tips below:
Referrer-Policy
header to no-referrer
.