Socket
Socket
Sign inDemoInstall

react-fbmessenger

Package Overview
Dependencies
21
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-fbmessenger

React components to emulate a messenger conversation


Version published
Weekly downloads
8
Maintainers
1
Created
Weekly downloads
 

Readme

Source

React components to generate a similar chat look to Facebook messenger

Useful to create mockups of messenger bot examples
Screenshot

Installation

$ npm install --save react-fbmessenger

Usage

The main components are Conversation and Container.

  • Conversation creates the chat bubbles and takes 3 props
    • conversation: An array of facebook send api messages
    • page_id: A string of the page's id, in order to differentiate the user vs bot's messages
    • postbackCallback: A function(payload) called when the viewer clicks a postback button
  • Container creates a chat box that includes the chat bubbles and a text entry area
    • Conversation's props
    • userTextCallback: A function(text) called when the user enters a text string
    • textFocusCallback: A function() called when the user clicks on the text area
    • textBlurCallback: A function() called when the text area loses focus
import React from 'react';
import ReactDOM from 'react-dom'
import { Conversation } from 'react-fbmessenger'

// if you use postcss include css directly or in html page
require('react-fbmessenger/out.scss') // is valid CSS (just rename)

const convo = [
{
  "recipient":{
    "id":"1"
  },
  "message":{
    "text":"hello user"
  }
},
{
  "recipient":{
    "id":"USER_ID"
  },
  "message":{
    "text":"hello bot"
  }
},
];

ReactDOM.render(
  <Conversation conversation={convo} page_id="1" />, 
  document.getElementById('root')
);

Example: https://fynd.me (demos and chat widget)

Extras not in messenger spec

  • System notifications
{
  "recipient":{
    "id":""@system"
  },
  "notification":{
    "text":"System notification"
  }
}

FAQs

Last updated on 16 Mar 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc