• Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    JavaScript
  • Created almost 7 years ago
  • Updated about 4 years ago

Reviews

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

Repository Details

A simple and beautiful React chat component backend agnostic and with Emoji and File support.

react-beautiful-chat

react-beautiful-chat provides an intercom-like chat window that can be included easily in any project for free. It provides no messaging facilities, only the view component.

react-beautiful-chat is an improved version of react-chat-window (which you can find here)

gif

Features

  • Customizeable
  • Backend agnostic
  • Free

Demo

Table of Contents

Installation

$ npm install react-beautiful-chat

Example

import React, {Component} from 'react'
import {render} from 'react-dom'
import {Launcher} from '../../src'

class Demo extends Component {

  constructor() {
    super();
    this.state = {
      messageList: messageHistory
    };
  }

  _onMessageWasSent(message) {
    this.setState({
      messageList: [...this.state.messageList, message]
    })
  }

  _sendMessage(text) {
    if (text.length > 0) {
      this.setState({
        messageList: [...this.state.messageList, {
          author: 'them',
          type: 'text',
          data: { text }
        }]
      })
    }
  }

  render() {
    return (<div>
      <Launcher
        agentProfile={{
          teamName: 'react-beautiful-chat',
          imageUrl: 'https://a.slack-edge.com/66f9/img/avatars-teams/ava_0001-34.png'
        }}
        onMessageWasSent={this._onMessageWasSent.bind(this)}
        messageList={this.state.messageList}
        showEmoji
      />
    </div>)
  }
}

For more detailed examples see the demo folder.

Components

Launcher

Launcher is the only component needed to use react-beautiful-chat. It will react dynamically to changes in messages. All new messages must be added via a change in props as shown in the example.

Launcher props:

prop type description
*agentProfile object Represents your product or service's customer service agent. Fields: teamName, imageUrl
onMessageWasSent function(message) Called when a message a message is sent with a message object as an argument.
messageList [message] An array of message objects to be rendered as a conversation.
showEmoji bool A bool indicating whether or not to show the emoji button
showFile bool A bool indicating whether or not to show the file chooser button
onKeyPress func A function (userInput) => console.log(userInput) used to do something with the user input. The function is invoked debounced at 300ms
onDelete func A function (msg) => console.log(msg) used to delete a sent message. If this props is set, a delete button will be shown in the top right corner of each message sent by the user to a partner. You can set any property on the message object (an id property for instance) and then use this property to call some backend api to delete the message.

Message Objects

Message objects are rendered differently depending on their type. Currently, only text and emoji types are supported. Each message object has an author field which can have the value 'me' or 'them'.

{
  author: 'them',
  type: 'text',
  data: {
    text: 'some text'
  }
}

{
  author: 'me',
  type: 'emoji',
  data: {
    code: 'someCode'
  }
}

{
  author: 'me',
  type: 'file',
  data: {
    name: 'file.mp3',
    url: 'https:123.rf/file.mp3'
  }
}

More Repositories

1

vue-beautiful-chat

A simple and beautiful Vue chat component backend agnostic, fully customisable and extendable.
Vue
1,480
star
2

vhost-creator

A simple bash script to create virtual host vhost with apache on Ubuntu or CentOS
Shell
25
star
3

bulmahead

Simple autocomplete for bulma.io
JavaScript
18
star
4

msgdown

*Simple* /messages/, _formatted_.
JavaScript
10
star
5

socializejs

Backend for a social network application
JavaScript
8
star
6

real-italian-recipes

๐Ÿ‡ฎ๐Ÿ‡น Real Italian Recipesโ„ข๏ธ
Python
7
star
7

timebombs

Stay clean, move fast!
Python
6
star
8

aclify

A simple and plain ACL component based on a YAML file.
PHP
4
star
9

email-sender

A python script that lets you send emails with string variables to a massive audience!
Python
4
star
10

qtws-store

A store for qtws - https://github.com/intersimone999/qtws
Ruby
3
star
11

mul

โŒจ๏ธ *mul* ยท My Useless Language, a simple interpreted programming language.
Python
3
star
12

fleet

A rapid and keep it stupid simple php rest boilerplate
PHP
3
star
13

sudokupy

Solve any sudoku, rapidly with ๐Ÿ
Python
3
star
14

flat-file-cms

Need a CMS module for your PHP webapp??? This one's based on flat text files! Enjoy it ๐Ÿ˜Š
PHP
3
star
15

italianTaxCode

Everybody loves to pay taxes! [-_-] This library lets you calculate Italian fiscal code with ease. It also reverts it to go back from the code to every (possible) original info. --- Calcola il codice fiscale a partire dai dati personali e viceversa.
Java
3
star
16

dotfiles

๐Ÿดโ€โ˜ ๏ธ my . files
Vim Script
3
star
17

FlatFileBlog

Need a blog module for you website? This one's based on flat files
PHP
3
star
18

todo

โœ… A small todo utility for terminal lovers.
Shell
2
star
19

php-logger

A tiny PHP logger
PHP
2
star
20

email-lang

The email language
JavaScript
2
star
21

cacheasy

I hate slow APIs, I cache things on disk.
PHP
2
star
22

FVA

Repository per il progetto di FVA: ear biometrics
Java
2
star
23

k8s-seminar-config

2
star
24

repominer-docs

Repominer documents
TeX
2
star
25

repominerEvo

repominer evolution gt 2
Java
2
star
26

bulvia

An easy to play Trivia game powered by Open Trivia, showcasing bulma.io :-)
Vue
2
star
27

react-matrix-decode

A react component to simulate a reveal of text with matrix decodification effect.
JavaScript
1
star
28

YouGis

An Android app to make mobile gis better
Java
1
star
29

deploysh

Auto deploy a PHP app with cron, bash, git and composer.
Shell
1
star
30

k8s-seminar-app

HTML
1
star
31

php-line-map

Map\CSV::file($usersCsv)->with(function ($row) { echo $row['name']; }); โ€“ Do stuff for each line of text
PHP
1
star
32

php-scheduled-job

A package to run scheduled job with cron.
PHP
1
star
33

mit-license-generator

A minimalistic MIT license generator
Shell
1
star
34

mattmezza

CLI CV `npx mattmezza`
JavaScript
1
star
35

note

๐Ÿ“ A small note taking utility for terminal lovers.
Shell
1
star
36

mattmezza.github.io

HTML
1
star
37

timer

A CLI timer for MacOS with notification support.
Shell
1
star
38

jump

๐Ÿ•ดNavigate directories from command line easily. Like autojump but without the learning bit.
Shell
1
star
39

knn-digit-char-recognition

This python program helps you kickstart with digits recognition using OpenCV and k-nearest-neighbor algorithm
Python
1
star
40

sp

ไท– Split your tmux window, quickly.
Shell
1
star
41

movie-streaming-collection

This wants to be the hugest and most accurate collection of movie streaming links of the world.
JavaScript
1
star
42

phava-chat-backend

A simple chat backend written in phava
PHP
1
star
43

tictactoe-cpp

TicTacToe C++
C++
1
star
44

email-lang-cli

The Email Language CLI
JavaScript
1
star
45

sprinkle-trivia

HTML
1
star
46

bloc

๐Ÿšซ block a website from the terminal
Shell
1
star