npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-messenger-chat-plugin

v3.0.5

Published

A react component for Facebook Messenger Chat Plugin with extra Customer Chat SDK features

Downloads

1,572

Readme

react-messenger-chat-plugin :speech_balloon: npm License: MIT size language

Table of contents

Installation

First, whitelist your domain to be eligible to use the messenger chat in facebooks page settings:

Facebook page > Settings > Messaging (in sidebar) > Add messenger to your website > Whitelist domain

:warning: NOTE: Facebook doesn't allow whitelisting localhost, so for dev-mode use a wrapper like ngrok.

npm

npm install react-messenger-chat-plugin

yarn

yarn add react-messenger-chat-plugin

Usage

MessengerChat Component

import React from "react";
import ReactDOM from "react-dom";
import { MessengerChat } from "react-messenger-chat-plugin";

ReactDOM.render(
  <MessengerChat
    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.

MessengerChat Control Functions

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.

import { MessengerChat, showMessenger, hideMessenger, showDialog, hideDialog, setMessengerHeight } from 'react-messenger-customer-chat';

function App() {

  return (
    <div className="App">
      <button onClick={() => {showMessenger(true)}}>show messenger</button>
      <button onClick={() => {hideMessenger()}}>hide messenger</button>
      <button onClick={() => {showDialog()}}>show dialog</button>
      <button onClick={() => {hideDialog()}}>hide dialog</button>
      <button onclick={() => {setMessengerBottomSpacing(100)}}>set chat 100px in bottom spacing<button>

      <MessengerChat pageId='123456789101112' />
    </div>
  );
}

export default App;

| Function | Description | | ------------------------------------------ | :-------------------------------------------------------------------------: | | setMessengerBottomSpacing(spacing: number) | Immediately sets height of messenger chat in pixels from bottom of the page | | showMessenger(shouldShowDialog: bool) | Shows the whole component | | hideMessenger() | Hides the whole component | | showDialog() | Expands dialog | | hideDialog() | Hides dialog |

Official docs

Facebook provides official docs for messenger customer chat plugin and chat plugin sdk which the package is based on.

Author

My name is Alexander Huang and you can find my linkedin here! Don't hesitate to contact and thank you for tuning in :raised_hands: