1.2.15 • Published 1 month ago

react-chat-window-clone v1.2.15

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

Warning!

This repo is not actively maintained or developed. PRs, issues, and feature requests may not receive any response.

Thank you for the support over the years for RCW! We appologize for the inconvenience.

react-chat-window

react-chat-window 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.

GitHub license

Demo gif of react-chat-window being used

Features

  • Customizeable
  • Backend agnostic
  • Free

Demo

Table of Contents

Installation

$ npm install react-chat-window

Example

import React, {Component} from 'react'
import {Launcher} from 'react-chat-window'

class Demo extends Component {

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

  _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-chat-window',
          imageUrl: 'https://a.slack-edge.com/66f9/img/avatars-teams/ava_0001-34.png'
        }}
        onMessageWasSent={this._onMessageWasSent.bind(this)}
        messageList={this.state.messageList}
        showEmoji
        showFilePicker
      />
    </div>)
  }
}

For more detailed examples see the demo folder.

Components

Launcher

Launcher is the only component needed to use react-chat-window. 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:

proptyperequireddescription
agentProfileobjectyesRepresents your product or service's customer service agent. Fields: imageUrl (string), teamName (string).
handleClickfunctionyesIntercept the click event on the launcher. No argument sent when function is called.
isOpenbooleanyesForce the open/close state of the chat window. If this is not set, it will open and close when clicked.
messageList[message]yesAn array of message objects to be rendered as a conversation.
mutebooleannoDon't play sound for incoming messages. Defaults to false.
newMessagesCountnumbernoThe number of new messages. If greater than 0, this number will be displayed in a badge on the launcher. Defaults to 0.
onFilesSelectedfunction(fileList)noCalled after file has been selected from dialogue in chat window.
onMessageWasSentfunction(message)yesCalled when a message is sent, with a message object as an argument.
showEmojibooleannoWhether or not to show the emoji button in the input bar. Defaults to true.
showFilePickerbooleannoWhether or not to show the file picker icon in the input bar. Defaults to true.
allowInputTextbooleannoWhether or not to allow user to input text in the input bar. Defaults to true.

Message Objects

Message objects are rendered differently depending on their type. Currently, only text, file, 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: {
    url: 'somefile.mp3',
    fileName: 'Any old name'
  }
}

Agent Profile Objects

Look like this:

{
  imageUrl: 'https://somewhere.on/the_web.png',
  teamName: 'Da best'
}
1.2.14

1 month ago

1.2.15

1 month ago

1.2.13

8 months ago

1.2.12

8 months ago

1.2.11

10 months ago

1.2.10

10 months ago

1.2.9

10 months ago

1.2.8

10 months ago

1.2.7

10 months ago

1.2.6

10 months ago

1.2.4

10 months ago

1.2.3

10 months ago

1.2.2

10 months ago

1.2.1

10 months ago

1.2.0

10 months ago