A react component for Facebook Messenger Chat Plugin with extra Customer Chat SDK features
npm install react-messenger-chat-plugin
sh
npm install react-messenger-chat-plugin
`
$3
`sh
yarn add react-messenger-chat-plugin
`
Usage
$3
`js
import React from "react";
import ReactDOM from "react-dom";
import { MessengerChat } from "react-messenger-chat-plugin";
ReactDOM.render(
pageId="109268111769502"
language="sv_SE"
themeColor={"#000000"}
bottomSpacing={300}
loggedInGreeting="loggedInGreeting"
loggedOutGreeting="loggedOutGreeting"
greetingDialogDisplay={"show"}
debugMode={true}
onMessengerShow={() => {
console.log("onMessengerShow");
}}
onMessengerHide={() => {
console.log("onMessengerHide");
}}
onMessengerDialogShow={() => {
console.log("onMessengerDialogShow");
}}
onMessengerDialogHide={() => {
console.log("onMessengerDialogHide");
}}
onMessengerMounted={() => {
console.log("onMessengerMounted");
}}
onMessengerLoad={() => {
console.log("onMessengerLoad");
}}
/>,
document.getElementById("demo")
);
`
| Attribute | Description | Default |
| -------------------------------- | :-------------------------------------------------------------------------------------------------: | :-----: |
| pageId (string) Required | Id of page which can be found on the facebook page | |
| language (string) | Language locale, e.g. 'en_US' for english or 'sv_SE' for swedish | "en_US" |
| themeColor (string) | Hexcode color of the theme color | |
| bottomSpacing (number) | Bottom spacing (px) | |
| greetingDialogDisplay (string) | Determine how the greeting dialog will be displayed. One of "hide", "show", "fade", "icon" | |
| greetingDialogDelay (number) | Sets the number of seconds of delay before the greeting dialog is shown after the plugin is loaded. | 0 |
| loggedInGreeting (string) | Greeting message displayed if user is logged in | |
| loggedOutGreeting (string) | Greeting message displayed if user is logged out | |
| onMessengerMounted (function) | Callback which is called when the messenger chat is mounted | |
| onMessengerLoad (function) | Callback which is called on load | |
| onMessengerShow (function) | Callback which is called when the component is shown. | |
| onMessengerHide (function) | Callback which is called when the component is hidden | |
| onMessengerDialogShow (function) | Callback which is called each time the dialog is expanded | |
| onMessengerDialogHide (function) | Callback which is called each time the dialog is hidden | |
| debugMode (bool) | Enables debug mode which console.logs every event in the component | false |
| version | Version of the messenger chat | "v13.0" |
> :warning: NOTE: some attributes can be controlled from your facebook page messenger chat plugin configurations. These are by default overriden by the props, so if you want more control from facebook -> populate less props.
$3
This package also supports control functions for the messenger chat which can be accessed globally. The control functions will only work after the messenger chat has succesfully mounted.
`js
import { MessengerChat, showMessenger, hideMessenger, showDialog, hideDialog, setMessengerHeight } from 'react-messenger-customer-chat';
function App() {
return (
);
}
export default App;
``