1.0.17 • Published 6 years ago

react-chatflow v1.0.17

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

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
fromstringyesuser - message from the real user, shown on the rightbot - message from the bot, shown on the leftsystem - 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

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago