• Stars
    star
    272
  • Rank 151,235 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

React component for messenger customer chat plugin

React Messenger Customer Chat

React component for Messenger customer chat plugin

npm Build Status License: MIT

Screenshots

Prerequisite

Whitelist your domain to connect your Facebook Page to your website via the Facebook tool.

  • From UI: Facebook Page Settings > Messenger Platform > Whitelisted Domains
  • From API: Use HTTP API or API client likes messaging-api-messenger

Installation

$ npm install react-messenger-customer-chat

Usage

import React from 'react';
import ReactDOM from 'react-dom';
import MessengerCustomerChat from 'react-messenger-customer-chat';

ReactDOM.render(
  <MessengerCustomerChat
    pageId="<PAGE_ID>"
    appId="<APP_ID>"
    htmlRef="<REF_STRING>"
  />,
  document.getElementById('demo'),
);

Note: It will handle sdk initialize automatically for you. See more details in Customer Chat Plugin official docs and Customer Chat SDK official docs.

Props

static propTypes = {
  pageId: PropTypes.string.isRequired,
  appId: PropTypes.string.isRequired,

  shouldShowDialog: PropTypes.bool,
  htmlRef: PropTypes.string,
  minimized: PropTypes.bool,
  themeColor: PropTypes.string,
  loggedInGreeting: PropTypes.string,
  loggedOutGreeting: PropTypes.string,
  greetingDialogDisplay: PropTypes.oneOf(['show', 'hide', 'fade']),
  greetingDialogDelay: PropTypes.number,
  autoLogAppEvents: PropTypes.bool,
  xfbml: PropTypes.bool,
  version: PropTypes.string,
  language: PropTypes.string,
  debug: PropTypes.bool,
  onCustomerChatDialogShow: PropTypes.func,
  onCustomerChatDialogHide: PropTypes.func,
};

static defaultProps = {
  shouldShowDialog: false,
  htmlRef: undefined,
  minimized: undefined,
  themeColor: undefined,
  loggedInGreeting: undefined,
  loggedOutGreeting: undefined,
  greetingDialogDisplay: undefined,
  greetingDialogDelay: undefined,
  autoLogAppEvents: true,
  xfbml: true,
  version: '2.11',
  language: 'en_US',
  debug: false,
  onCustomerChatDialogShow: undefined,
  onCustomerChatDialogHide: undefined,
};

Next.js/SSR

To make <MessengerComponent /> work with Server-Side Rendering (SSR), you need to avoid rendering it on the server:

{
  typeof window !== 'undefiend' && (
    <MessengerComponent
      pageId="<PAGE_ID>"
      appId="<APP_ID>"
      htmlRef="<REF_STRING>"
    />
  );
}

Troubleshooting Tips

If you're having trouble getting the plugin to render properly, try the tips below:

  • If you see a console error like "Refused to display _ in a frame because an ancestor violates the following Content Security Policy directive: _", check that the domain of the page the plugin is being rendered on has been whitelisted. Also make sure you didn't set the Referrer-Policy header to no-referrer.
  • The Firefox Facebook Container Add-On prevents the plugin from showing up. Remove the add on if you want the plugin to render.
  • Firefox desktop private browsers (version 63 and above) and Firefox mobile browsers block content tracking by default which will prevent the plugin from rendering. Turn off content blocking (click the gray shield in the search bar) to see the plugin render.

Related

License

MIT © Yoctol

More Repositories

1

bottender

⚡️ A framework for building conversational user interfaces.
TypeScript
4,221
star
2

react-d3-cloud

A word cloud react component built with d3-cloud.
TypeScript
141
star
3

seq2vec

Transform sequence of words into a fix-length representation vector
Python
68
star
4

ADEM

TOWARDS AN AUTOMATIC TURING TEST: LEARNING TO EVALUATE DIALOGUE RESPONSES
Python
28
star
5

fetch-graphql-schema

fetch GraphQL schema via introspection query
JavaScript
27
star
6

leader-of-lunch

LOL
TypeScript
19
star
7

yoctol-keras-layer-zoo

Some customized keras layers used in Yoctol NLU.
Python
19
star
8

react-messenger-send-to-messenger

React component for messenger send to messenger plugin
JavaScript
17
star
9

text-normalizer

Normalize text string
Python
13
star
10

react-messenger-message-us

React component for messenger message us plugin
JavaScript
10
star
11

tailor-ui

A bespoke UI collection for building web application.
TypeScript
10
star
12

yoctol-nlu-py

Yoctol understood SDK for python.
Jupyter Notebook
10
star
13

react-messenger-checkbox

React component for messenger checkbox plugin
JavaScript
10
star
14

HRED

Hierarchical Encoder Decoder RNN
Python
8
star
15

serving-utils

Some utilities for tensorflow serving
Python
8
star
16

agricola-score

農家樂分數計算機
JavaScript
7
star
17

ansible-docker-postgres

Ansible role to run postgres container.
6
star
18

tw-stock-info-bot

JavaScript
5
star
19

bookshelf-test-utils

JavaScript
5
star
20

bottender-google-sheet-sync-demo

a demo of google sheets api on bottender
JavaScript
5
star
21

eslint-config-yoctol

Yoctol specific linting rules for ESLint
JavaScript
5
star
22

strpipe

text preprocessing pipeline
Python
5
star
23

async-update-props

JavaScript
4
star
24

us-stock-info-bot

JavaScript
4
star
25

DS-post-interview-assignment

A Post Interview Assignment for Candidates.
Python
4
star
26

stylelint-config-yoctol

Yoctol's stylelint config
JavaScript
3
star
27

purewords

Create pure sentences
Python
3
star
28

word-embedder

Get pretrained word embedding
Python
3
star
29

ansible-env-file

Role to render env file with ease.
3
star
30

bookshelf-plugin

Yoctol specific plugins for Bookshelf
JavaScript
2
star
31

talos

Neural Network Builder
Python
2
star
32

hubot-messenger-bot-adapter

A Hubot adapter for Facebook Messenger Platform
JavaScript
2
star
33

eslint-config-yoctol-base

Yoctol specific base linting rules for ESLint
JavaScript
2
star
34

yoctol-nlu-node

Yoctol Natural Language Understanding SDK for Node.js
JavaScript
2
star
35

yoctol-printer

print files using web interface
JavaScript
2
star
36

messenger-batch

Gracefully batching messenger requests.
JavaScript
1
star
37

ansible-dockerfile

1
star
38

koa-final-handler

Final handler middleware for koa.
JavaScript
1
star
39

uttut

Utterance utilities.
Python
1
star
40

liff-test

Using Bottender to test behavior of LIFF in any situation.
JavaScript
1
star
41

react-paperjs-experiment

JavaScript
1
star
42

flake8-config-yoctol

Yoctol Flake8 config
Python
1
star
43

ddenv

Debug Friendly Environment
JavaScript
1
star
44

babel-preset-yoctol

Yoctol specific configuration for Babel
JavaScript
1
star