🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

react-chatflow

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-chatflow

[![npm version](https://img.shields.io/npm/v/react-chatflow.svg?style=flat)](https://www.npmjs.com/package/react-chatflow)

latest
Source
npmnpm
Version
1.0.17
Version published
Weekly downloads
1
-88.89%
Maintainers
1
Weekly downloads
 
Created
Source

React Chatflow

npm version

React library that helps you to emulate a simple chatflow between a real user and a bot.

Installation

Download the package:

npm install --save react-chatflow

Basic usage

import Chatflow from 'react-chatflow';

const messages = [
    {message: '- Conversation start -', from: 'system'},
    {message: "Josh, I need your email to register on our service", from: "bot"},
    {message: "sure", from: "user"},
    {message: "josh@email.com", from: "user"},
    {message: "thx, Josh", from: "bot"},
    {message: "and your phone number", from: "bot"},
    {message: '- Some system message again -', from: "system"},
    {message: "+47-JOSH-PHONE", from: "user"},
    {message: "great, thanks a lot", from: "bot"},
    {message: "have a nice day!", from: "bot"}
];

<Chatflow
    messages={messages}
/>

Properties

PropertyTypeDefault valueDescription
messagesarray-Array of messages to display (see message structure for detailed info)
widthnumber300Width (in px) of chat area
heightnumber300Height (in px) of chat area
typingDurationnumber1000Duration (in ms) while the typing indicator is shown for each message
messageDelaynumber1500Delay (in ms) before each message is shown
onInitfunction-Callback that is called with no params after the init
autoPlayboolfalseIf set to true, messages will start showing without the user interaction
messageClassNamestring-Custom class name that will be added to each message
leftMessageClassNamestring-Custom class that will be added to each message from the bot
rightMessageClassNamestring-Custom class that will be added to each message from the real user
systemMessageClassNamestring-Custom class that will be added to each message from the system
messageTextClassNamestring-Custom class that will be added to the text of each message
containerClassNamestring-Custom class that will be added to the chat container
messageAvatarClassNamestring-Custom class name that will be added to each avatar
typingIndicatorClassNamestring-Custom class name that will be added to the typing indicator
typingIndicatorInnerClassNamestring-Custom class name that will be added to the inner part of the typing indicator
startBtnClassNamestring-Custom class name that will be added to the button that starts the chatflow

Message structure

FieldTypeRequiredDescription
messagestringyesDisplayed text
fromstringyes
  • user - message from the real user, shown on the right
  • bot - message from the bot, shown on the left
  • system - system message, shown in the middle
delaynumbernoCustom delay (in ms) before this message is shown
typingDurationnumbernoCustom duration (in ms) while the typing indicator is shown for this message

Licence

MIT

FAQs

Package last updated on 13 Aug 2018

Did you know?

Socket

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