npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react--customizable-chat-bot

v1.0.6

Published

React Customizable Chat Bot Component

Downloads

15

Readme

Build your own chatbot with minimal changes

Live Demo live demo

Comes with 5 predefined styles and you can define your own styles as well

Installation

npm install react--customizable-chat-bot or Yarn add react--customizable-chat-bot

Usage

List of questions to be asked by bot the can be passed . Take a look at example questions structure here!

import { Bot, BotConfig } from 'react--customizable-chat-bot'

BotConfig has some default set of questions and styles which you can override.

Adding Validators to user response

If you need to validate user response , under each question we have a handlers where you can pass validators to validate user response and drive the chat accordingly.

Validators can either be a regex or a function which returns boolean

BotConfig.questions = [{'dob': {
            id: 1,
            message: "What's your Date of Birth (DD/MM/YYYY)?",
            questionKey : 'dob',
            handlers: [
                {
                    validators: dateReg,
                    nextQuestion: 'email',
                },
                {
                    validators: dateRegNeg,
                    nextQuestion: 'dobWrong',
                },
            ],
        }},'dobWrong': {
            id: 2,
            message: "Please enter a valid date of birth",
            questionKey : 'dob',
            handlers: [
                {
                    validators: dateReg,
                    nextQuestion: 'email',
                },
                {
                    validators: dateRegNeg,
                    nextQuestion: 'dobWrong',
                },
            ],
        }];

Customizing the Styles

By Default there are 5 themes available

1.)Default,
2.)GoogleAssitant,
3.)Facebook,
4.)WhatsApp, 
5.)GradientGreen   

You can chose any of these themes as below

import { Bot, BotConfig } from 'react--customizable-chat-bot'
import { Themes } from 'react--customizable-chat-bot/lib/config/config';

BotConfig.Theme = Themes.GoogleAssitant;

You can entirely redefine the ui styles based on your brand. Take a look at List of custom style option available here!

Once your styling is ready you can pass it as a props to the bot component

import { Bot, BotConfig , IStyles } from 'react--customizable-chat-bot' 

const myStyles: IStyles = {
    primaryColor: "#4870df",
    sendButtonColor: "#4870df",
    userAvatar: '',
    userAvatarColor: '#4870df',
    userAvatarTextColor: '#fff',
    botAvatar: "https://i.ibb.co/NxZqGVN/bot-avatar.png",
    botAvatarColor: '#e6e5eb',
    botAvatarTextColor: '#000',
    bubbleRadius: "0",
    botMessageBubbleColor: '#4870df',
    botMessageTextColor: '#fff',
    userMessageBubbleColor: '#e6e5eb',
    userMessageTextColor: '#000',
    inputBoxBorderRadius: '40px',
    primaryLabelColor: '#000',
}

export const MyFunc() => <Bot config={BotConfig}  customStyles={myStyles}/>

You should pass a function to onConversationEnd props of Bot component to get the conversation data which we will a json string

import { Bot, BotConfig } from 'react--customizable-chat-bot' 

const onConversationEnd = (converstationData : string ) => {
    console.log(converstationData);
}

export const MyFunc() => <Bot config={BotConfig}  onConversationEnd={onConversationEnd}/>