GithubHelp home page GithubHelp logo

lucasbassetti / react-simple-chatbot Goto Github PK

View Code? Open in Web Editor NEW
1.7K 1.7K 593.0 5.04 MB

:speech_balloon: Easy way to create conversation chats

Home Page: https://lucasbassetti.com.br/react-simple-chatbot/

License: MIT License

JavaScript 99.73% HTML 0.27%
chat chatbot conversational-ui react

react-simple-chatbot's Introduction

Warning

React Simple Chatbot is no longer maintained. I recommend using react-chatbotify as an alternative.

React Simple Chatbot

Travis CI npm version Codecov

A simple chatbot component to create conversation chats

Getting Start

npm install react-simple-chatbot --save

Usage

There are several examples on the website. Here is the first one to get you started:

import ChatBot from 'react-simple-chatbot';

const steps = [
  {
    id: '0',
    message: 'Welcome to react chatbot!',
    trigger: '1',
  },
  {
    id: '1',
    message: 'Bye!',
    end: true,
  },
];

ReactDOM.render(
  <div>
    <ChatBot steps={steps} />
  </div>,
  document.getElementById('root')
);

React Simple Chatbot on media

  1. webdesignerdepot
  2. blogduwebdesign
  3. codrops

Build with react-simple-chatbot

  1. Seth Loh Website - Personal website of Seth Loh (demo)
  2. Paul's Website - Personal website of Paul Jiang (demo)
  3. Cisco Partner Support API Chatbot - Code with screenshots to have your own Cisco Serial lookup chatbot.
  4. Chatcompose - Chatbot Platform for Conversational Marketing and Support.
  5. Mixat - News Chatbot for tweenies. Also as app (iOS or Android)

Built something with react-simple-chatbot? Submit a PR and add it to this list!

How to Contribute

Please check the contributing guide

Authors

Lucas Bassetti
Lucas Bassetti

See also the list of contributors who participated in this project.

License

MIT ยท Lucas Bassetti

react-simple-chatbot's People

Contributors

btotharye avatar chapmanc avatar cyclodex avatar dependabot[bot] avatar digitalwestie avatar dmr avatar gamedevsam avatar lazerwalker avatar lucasbassetti avatar olofsvt avatar pascalgagneur avatar pgerlich avatar psheon avatar puemos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-simple-chatbot's Issues

Trigger not working

I am trying to implement my own Chat bot. I am totally stuck in the first example "Previous Values". The option Trigger is not working for me. Please help me in understanding where I am going wrong.

Below is the code.

import React from 'react';
import ReactDOM from 'react-dom';
import ChatBot from 'react-simple-chatbot';


const steps = [
    {
      id: '1',
      message: 'What is your name?',
      trigger: '2',
    },
    {
      id: '2',
      user: true,
      trigger: '3',
    },
    {
      id: '3',
      message: 'Hi {previousValue}, nice to meet you!',
      end: true,
    },
  ];



ReactDOM.render(
  <div>
    <ChatBot steps={steps} />
  </div>,
  document.getElementById('root')
);

Styled-Components throws console error

When loading the library with a fresh npm install I get the following.

ThemeProvider.js:63 Warning: Usage of context.styled-componentsas a function is deprecated. It will be replaced with the object on.context.styled-components__next` in a future version.

Fixed this by explicitly downgrading my peer dependency from ^2.2.1 to ^2.1.2 for the time being.

[Help] Save messages rendered

I am trying to figure out a way to save the messages, so the rendersteps are cached and when user come back they are exactly back where they were.

Passing a function into options

Hi, what I am trying to do is to connect the options to a React props thus I can change the value and label of the options every time I update the props. for the message I could be doing

message: () => {
return this.props.text;
}

However,
options: this.props.options will only take in the options at initial state
and
options: () => {
return this.props.options;
}
will result in a error basically saying that options can only be a object

[Enhancement] Remove option repeating user message.

I am trying to implement a feature I can use if (currentStep.options && data) in ChatBot.jsx to remove repeating to the option as a user and not directing sending the to trigger message. I tried deleting if statements and parts of it. But I am unable to achieve the desired effect.

Theming

Hi, I really like your simple chatbot code, thank you!

To apply it in my projects I'd have to change the style quite a bit and I was wondering if you would accept a pullrequest that implemented "Theming" as described in styled-components:
https://www.styled-components.com/docs/advanced#theming

This is just a first thought but how do you feel about the idea?

[Help] Creating a close button in chat ui

So I have been modifying around to create this.
I believe you have to be inside a step to be able to render (w/ previous, and trigger)

Creating a button like on chatbot.js
<button onClick={() => this.triggerB}>Continue</button> triggerB() { this.triggerNextStep(); }

it seems to me the only way to do this is by using redux to have the data pass up, however, if there an alternative or an idea I would appreciate some input.

Is there any way to take in user text input and buttons options at the same time?

I want to give the option to do both methods of user interaction. Here's my code so far.

            {
              id: '3',
              user: true,
              options: [
                        { value: 1, label: 'Get a Quote', trigger: '4' },
                        { value: 2, label: 'Service Request', trigger: '5' },
                        { value: 3, label: 'Request Documents', trigger: '6' },
                        { value: 4, label: 'Talk To Us', trigger: '7' },
                      ],
              trigger: ({ value, steps }) => {
                console.log(steps);

                  if(value ==="Get a Quote"){
                    return "4"
                  }
                  else if(value ==="Service Request"){
                    return "5"
                  }
                  else if(value ==="Request Documents"){
                    return "6"
                  }
                  else if(value ==="Talk To Us"){
                    return "7"
                  }
              }
            },

This is just something I tried. I don't see the options buttons, but the text input triggers are working properly.

1. Callback on user input 2. Dynamic value setting for step responses

So I'm looking at implementing this, and have gotten almost completely through doing what I want to do.

I do have two feature requests, the later of which I will open a PR for this week.

  1. You should be able to provide a callback such as 'onUserInput' which allows the parent component to know what the user is saying. This is necessary if you want your users to have a truly dynamic conversation. For now, I am using the 'validator' to store the value and kick off any actions which may be associated with the user input.

  2. Going off of the last point, it is crucial that you can update steps dynamically and that the chatBox accepts new steps and swaps them out for the steps it has in its state, assuming that the new steps pass a 'sanity check'. This would be the second piece in allowing dynamic conversations, thereby allowing the user to drive the discussion, rather than having a pre-planned interaction which has limited uses.

There is probably an alternative to the second case, but that seems like the best option right now. Bear in mind I just picked this code up today.

Thanks!

Custom component not receiving updated props in componentWillReceiveProps()

import React from "react";
import PropTypes from "prop-types";
import ChatBot from 'react-simple-chatbot';
import {renderBooksList, emailValidator} from "../../utility";
import io from 'socket.io-client';

class Home extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            hello : ""
        }
        this.user = {
            name: ''
        }
    }

    getCredentials = (value, type) => {
        switch (type) {
            case 'name':
                this.user.name = value;
                break;
            default:
                break;
        }
    }

    addUser = (user) => {
        let details = Object.assign({}, user, this.user);
        this.props.addNewUser(details);
    }

    componentWillReceiveProps(nextProps, prv) {
        if(!_.isEmpty(nextProps.user) && nextProps.user.isAdmin )
            nextProps.history.push('/admin');
        else
            this.setState({hello: "abcd"});
    }

    render() {
        return (
            <section className="container bg-gray">
                <div className="wraper">
                    <Nouse {...this.props} {...this.state}/>
                    <ChatBot
                        steps={[
                            {
                              id: '1',
                              message: 'What is your name?',
                              trigger: '2',
                            },
                            {
                              id: '2',
                              user: true,
                              validator: (value) => {
                                if (!value) {
                                  return 'We will need your credentials';
                                }
                                this.getCredentials(value, 'name');
                                return true;
                              },
                              trigger: '3',
                            },
                            {
                              id: '3',
                              message: 'Hi {previousValue},what would you like to enter?',
                              trigger: '4'

                            },
                            {
                              id: '4',
                              options: [
                                  {  value: 'id', label: 'Id/Password', trigger: '5' },
                                  {  value: 'email', label: 'Email', trigger: '6' },
                                ]
                              //validator: (value) => {
                              //  //if (!emailValidator(value)) {
                              //  //  return 'Please enter valid email';
                              //  //}
                              //  this.getCredentials(value, 'email');
                              //  return true;
                              //},
                            },
                            {
                              id: '5',
                              component : <InputForm addUser={this.addUser} option={true} {...this.props} {...this.state}/>,
                              waitAction: true,
                              trigger : '7'
                            },
                            {
                              id: '6',
                              component : <InputForm addUser={this.addUser} option={false}/>,
                              waitAction: true,
                              trigger : '7'
                            },
                            {
                              id: '7',
                              message : "Great!!done",
                              end : true
                            },
                          ]}
                        />
                </div>
            </section>
        )
    }
}

Home.propTypes = {
    history: PropTypes.object.isRequired,
    addNewUser: PropTypes.func.isRequired,

};

export default Home;


class InputForm extends React.PureComponent {
    constructor(props) {
        super(props);
        this.details = {
            userid: '',
            password: '',
            email: ''
        }
    }

    onChange = (type, evt) => {
        switch (type) {
            case 'userid':
                this.details.userid = evt.target.value;
                break;
            case 'password':
                this.details.password = evt.target.value;
                break;
            case 'email':
                this.details.email = evt.target.value;
                break;
            default:
                break;
        }

    }

    onSubmit = (evt) => {
        evt.preventDefault();
        this.props.addUser(this.details);
        //this.props.triggerNextStep();
    }

    componentWillReceiveProps(nextProps, prv) {
        if(!_.isEmpty(nextProps.user) && !_.isEmpty(nextProps.user.isAdmin))
            nextProps.history.push('/admin');
        else if(!_.isEmpty(nextProps.user))
            nextProps.triggerNextStep();
    }

    render() {
        const { option } = this.props;
        return (
            <div className="container">
                {_.isEmpty(this.props.user) ?
                    <div>
                        { this.props.option ? (
                            <form className="form-horizontal" onSubmit={this.onSubmit}>
                                <div style={{"marginBottom": "25px"}} className="input-group">
                                    <span className="input-group-addon"><i
                                        className="glyphicon glyphicon-user"></i></span>
                                    <input className="form-control" defaultValue="" placeholder="userid"
                                           onChange={this.onChange.bind(this,'userid')}/>
                                </div>
                                <div style={{"marginBottom": "25px"}} className="input-group">
                                    <span className="input-group-addon"><i
                                        className="glyphicon glyphicon-lock"></i></span>
                                    <input type="password" className="form-control" defaultValue=''
                                           placeholder="password"
                                           onChange={this.onChange.bind(this,'password')}/>
                                </div>
                                <div style={{"marginTop":"10px"}} className="form-group">
                                    <div className="col-sm-12 controls">
                                        <button type="submit" className="btn btn-success">Submit</button>
                                    </div>
                                </div>
                            </form> ) : (
                            <form className="form-horizontal" onSubmit={this.onSubmit}>
                                <div style={{"marginBottom": "25px"}} className="input-group">
                                    <span className="input-group-addon"><i
                                        className="glyphicon glyphicon-user"></i></span>
                                    <input className="form-control" defaultValue="" placeholder="email"
                                           onChange={this.onChange.bind(this,'email')}/>
                                </div>
                                <div style={{"marginTop":"10px"}} className="form-group">
                                    <div className="col-sm-12 controls">
                                        <button type="submit" className="btn btn-success">Submit</button>
                                    </div>
                                </div>
                            </form>)
                        }
                        </div>
                     : <div></div> }
            </div>
        );
    }
}

class Nouse extends React.PureComponent{
    constructor(){
        super();
        console.log("construnctor called");
    }

    componentWillReceiveProps(nextProps,pv){
        console.log("nouse nextprops", nextProps);
    }
        render(){
            return(<div>nouse </div>);
        }
    }

I have made two child components Nouse and InputForm, when I dispatch an action I get updated props in Nouse component but not in InputForm component which is child-component of Chatbot. Can you Please check whta's the issue.

Override properties doesn't work

I'm trying to override new properties but it doesn't work

ChatBot.headerTitle = 'Welcome'; ChatBot.floating = true; ChatBot.botAvatar = 'http://www.somewebsite.com/img/chat.png; ChatBot.opened = false; ChatBot.placeholder = 'Type something';

Changing // loading additional steps based on user input

I'm trying to have the bot be able to load extra steps from the backend for instance, but I'm not able to modify the steps without triggering errors.

I've tried both with modifying the 'steps' Object passed to the trigger: transition_function or modifying the list of steps contained in the steps.

Is there a mechanism so I can add steps (instead of defining them all in advance).

Here is the code:

class GeneralBot extends React.Component {

  constructor(props) {
    super(props);

    this.state = {

      // bot state machine
      steps: [
        {

          id: 'start', // start node
          message: 'Hello',
          trigger: 'user_entry'

        },

        { id: 'user_entry',
          user: true,
          trigger: this.user_transition
        },

        { id: 'end',
          message: this.end_messsage,
          end: true
        }

      ]
    };
  }

  add_step = (step) => {
    const new_steps = this.state.steps.concat(step);
    this.setState({
      steps: new_steps
    });
  }

  user_transition = ({ value, steps }) => {
    console.log("USER INPUT transition");
    console.log("value:", value);
    console.log("steps:", steps);

    const new_step = {
      id: 'user_entry_response',
      message: 'You said something',
      trigger: 'end'
    };

    // create an entirely new state and transition onto it
    console.log("adding step to bot, by modifying state");
    this.add_step(new_step);
    console.log("state:", this.state.steps);

    console.log("adding step to bot by modifyng 'steps' object");
    steps['user_entry_response'] = new_step;
    console.log("steps:", steps);

     // jump onto the new state added
    console.log("jumping to user_entry_response");
    return "user_entry_response";

    //console.log("jumping to end");
    //return "end";
  }

  render() {
    return (
      <ChatBot
        floating={true}
        botDelay={2500}
        customDelay={50}
        steps={this.state.steps}
        />
    );
  }

}```

Any way to trigger a step from user text input?

I only see examples for triggers steps based on clicking on buttons in the options example. Is there a way trigger different steps based on the value of the "user: true" response ?

For example, can something like this be done? here's what I'm thinking in rough pseudo code.

if ({previousValue} === "yes") {
     trigger("2");
}

Full size not auto scrollable on mobile ?

Hello Lucas!

Thanks for your amazing react chatbot!

I tried to put a 100vh heigh on mobile to display the chatbot window but when a new component is rendered, there is no auto scrolling :(

Any solution ?

Best,
Florian

Confused about Toggle documentation and functionality

Hi Lucas,

First off, thanks a ton for this amazing simple bot!

Here is my problem I have been stuck on for a bit. I am having trouble understanding the documentation for the toggle functionality. I am looking to replicate the exact same functionality you have on the bot website. Which is, when clicking a link inside the chat (like the one you have to redirect to the installation page), I am redirected to the appropriate page, then the chat closes.

I understand I need to use the opened prop along with the toggleFloating prop and then my own function. But I don't understand what the documentation means by: "Must be used with opened prop. You must use it to change your opened prop using your custom function like myToggleFloating({ opened })".

I was hoping you could give me an example of how you did it.

Here is my code simplified without all my failed attempts at adding these props:

import React, {Component} from 'react';
import {Link, withRouter} from 'react-router-dom';
import './styles.css';
import ChatBot from 'react-simple-chatbot';

class mrChatBot extends Component{
    handleAbout = ()=>{
        this.props.history.push('/about');
        return "3"
    }

    render(){
        return(
        <ChatBot floating={true} placeholder="Type your message..."
                steps={[
                        {
                            id: '1',
                            message: 'What can I help you with?',
                            trigger: '2',
                        },
                        {
                        id: '2',
                            options: [
                                { value: 1, label: "About", trigger: this.handleAbout, },
                            ],
                        },
                        {
                            id: '3',
                            message: 'You have been redirected!',
                            end: true,
                        },
                ]}
            />
        )
    }
}
        
export default withRouter(mrChatBot);

Thank you!

I think you might have left out binding these functions

`closeChatBot({ opened }) {
if (this.props.toggleFloating) {
this.props.toggleFloating({ opened });
} else {
this.setState({ opened });
}
}

openChatBot({ opened }) {
if (this.props.toggleFloating) {
this.props.toggleFloating({ opened });
} else {
this.setState({ opened });
}
}`

Add a submit/send button to the user input area

Hi Lucas,

First of all thanks so much for an amazing piece of open source ๐Ÿ‘

One thing that I think could be really helpful is to add a submit/send button to the user input area, like the below screenshot.

screen shot 2017-07-20 at 2 58 36 pm

Main reason being is that if you're using the chatbot on a mobile device and you enter something into the input and hit the done button then it doesn't submit. You need to hit the return button to get it to submit. See screenshot below

image uploaded from ios 2

So I think there may be 2 solutions:

  1. Add a submit button like suggested above
  2. Done button on the keyboard also submits the form (not sure if possible)

Thanks again, look forward to hearing back from you.

Regards
Bo

Missing trigger state in Wikipedia Tutorial Sample Code

render() { const { loading, result } = this.state;
should be revised to

render() { const { loading, result, **trigger** } = this.state;
I'm not entirely sure why the query isn't working despite the fix (not familiar with DBpedia)

Doesn't 100% width on mobile

Hi Lucas, thank you first, here is my question, i'm using node 8.1.4 and latest chrome
and my Dialog box did not 100% width on mobile user
I hope you can answer for me : )

default

1

Complete setup steps

Hi,
this project looks interesting. I've worked with node before, but not with all the tools this project uses. Can you give a complete list of setup steps to get it working?

  1. git clone https://github.com/LucasBassetti/react-simple-chatbot.git
  2. change "name" in package.json (npm can't install a package with the same name as the project)
  3. npm install
  4. npm install react-simple-chatbot --save

Now all tests are passing (npm test), but when running npm start I get

ERROR in multi main
Module not found: Error: Cannot resolve 'file' or 'directory' /home/test/Desktop/react-simple-chatbot/app/js/main in /home/test/Desktop/react-simple-chatbot
 @ multi main
webpack: Failed to compile.

How do I make the server work? Where to put the example files and how to name them?

What about Google Analytics?

Hi there,

first of all, thanks for the project, it's really nice and easy to use. I'm playing around with the posibility of integrate it on an ecommerce and could be very nice in order to find out products and services. As marketer guy, I would like to analyse and track the use of the chat. Is there any way to send data to Google Analytics of user behaviour? (any kind of hit -event, pageview, etc-)

Thank you!

Custom cache

Hi๏ผŒi have two bots in the same page
what should I do if I want cache both messages with different localstorage item name

Uncaught TypeError: this.updater.enqueueCallback is not a function. Example seems stuck at "asking for user input", but has input box greyed out.

React: "react": "^16.0.0",
Node: v8.4.0
NPM 5.4.2

My steps are:

  1. create react app
  2. npm run start
  3. create separate file for BMI component example
  4. import BMI component into app.js
  5. go to localhost 3000

The development server starts and I go to local host 3000. This is what I see.
alt text

My code is below. Basically just create react app with the BMI component.

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import ChatBot from 'react-simple-chatbot';
import BMIExample from './BMIExample';

class App extends Component {
  render() {
    return (
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h1 className="App-title">Welcome to React</h1>
        </header>
        <p className="App-intro">
          To get started, edit <code>src/App.js</code> and save to reload.
        </p>
        <BMIExample/>
      </div>
    );
  }
}

export default App;

The error I get my browser is :

react-simple-chatbot.js:1 Uncaught TypeError: this.updater.enqueueCallback is not a function
    at t.r.setState (react-simple-chatbot.js:1)
    at react-simple-chatbot.js:1

Conditional next step

Hi,

This looks very good!

From what I can see, there is no support for conditional next step.

Will this be added in the future?

Thanks :)

How to integrate with wit.ai or api.ai ?

Thanks for such a nice UI first.

I would like to know.
Is steps can only be pre-defined or they can be dynamic.
Because,that's how a real life chatbot will be made,on a nlp platform.
But,I have tried updating state assigned to step props.But,It doesn't update the conversation.
A good example for dynamic Steps would be great.

Branching some steps into a separate component

@LucasBassetti , this is a very cool project. thanks.

I am trying to branch off some steps into an independent component. For example if SimpleForm is made into a separate component, then i can render that wherever Form is required in the conversation. Can you give some pointers on how to achieve this? I tried to do this with and but these elements cannot take steps[] . Some guidance or an example to this effect will be of much help.

Error with webpack

When I run npm run build I get the following error.

โ€บ npm run build

> [email protected] build /Users/yesthis/rchat
> webpack --config webpack.config.prod.js

clean-webpack-plugin: /Users/yesthis/rchat/dist has been removed.
Hash: 6e4e3f42d328d295e90f
Version: webpack 1.15.0
Time: 4153ms
                  Asset     Size  Chunks             Chunk Names
react-simple-chatbot.js  1.09 MB       0  [emitted]  main
    + 149 hidden modules

ERROR in react-simple-chatbot.js from UglifyJs
TypeError: Cannot read property 'reset' of undefined
    at /Users/yesthis/rchat/node_modules/webpack/lib/optimize/UglifyJsPlugin.js:81:19
    at Array.forEach (native)
    at Compilation.<anonymous> (/Users/yesthis/rchat/node_modules/webpack/lib/optimize/UglifyJsPlugin.js:44:10)
    at Compilation.applyPluginsAsync (/Users/yesthis/rchat/node_modules/tapable/lib/Tapable.js:71:13)
    at Compilation.<anonymous> (/Users/yesthis/rchat/node_modules/webpack/lib/Compilation.js:567:9)
    at Compilation.applyPluginsAsync (/Users/yesthis/rchat/node_modules/tapable/lib/Tapable.js:60:69)
    at Compilation.<anonymous> (/Users/yesthis/rchat/node_modules/webpack/lib/Compilation.js:563:8)
    at Compilation.applyPluginsAsync (/Users/yesthis/rchat/node_modules/tapable/lib/Tapable.js:60:69)
    at Compilation.seal (/Users/yesthis/rchat/node_modules/webpack/lib/Compilation.js:525:7)
    at Compiler.<anonymous> (/Users/yesthis/rchat/node_modules/webpack/lib/Compiler.js:397:15)
    at /Users/yesthis/rchat/node_modules/tapable/lib/Tapable.js:103:11
    at Compilation.<anonymous> (/Users/yesthis/rchat/node_modules/webpack/lib/Compilation.js:445:10)
    at /Users/yesthis/rchat/node_modules/webpack/lib/Compilation.js:417:12
    at /Users/yesthis/rchat/node_modules/webpack/lib/Compilation.js:332:10
    at /Users/yesthis/rchat/node_modules/async/lib/async.js:52:16
    at done (/Users/yesthis/rchat/node_modules/async/lib/async.js:246:17)
    at /Users/yesthis/rchat/node_modules/async/lib/async.js:44:16
    at /Users/yesthis/rchat/node_modules/webpack/lib/Compilation.js:332:10
    at /Users/yesthis/rchat/node_modules/async/lib/async.js:52:16
    at done (/Users/yesthis/rchat/node_modules/async/lib/async.js:246:17)
    at /Users/yesthis/rchat/node_modules/async/lib/async.js:44:16
    at /Users/yesthis/rchat/node_modules/webpack/lib/Compilation.js:332:10
    at /Users/yesthis/rchat/node_modules/async/lib/async.js:52:16
    at done (/Users/yesthis/rchat/node_modules/async/lib/async.js:246:17)
    at /Users/yesthis/rchat/node_modules/async/lib/async.js:44:16
    at /Users/yesthis/rchat/node_modules/webpack/lib/Compilation.js:332:10
    at /Users/yesthis/rchat/node_modules/async/lib/async.js:52:16
    at done (/Users/yesthis/rchat/node_modules/async/lib/async.js:246:17)
    at /Users/yesthis/rchat/node_modules/async/lib/async.js:44:16
    at /Users/yesthis/rchat/node_modules/webpack/lib/Compilation.js:332:10

Are there any way to response the value on User Side from Custom Component!

hi, Lucas

thx for the great works! I am using "react-simple-chatbot": "^0.2.6",
I have been look over the api , are there any way to response the value as user input by

 this.setState({ trigger: true }, () => {
       this.props.triggerNextStep( { value: value });
     });
  1. Since, I created my custom option component, by select a value, even thought, I return by triggerNextStep! It wasn't displayed as user input in Step #3! e.g. when i inputed my name in Step#1, my name got display on the right!

  2. And also, couldn't find a way to display the SubmitButton. (note: even set is as hideSubmitButton="false"

p1
p2
p3

bye now!

Examples do not progress past step 1

I seem to have this strange issue where the examples do not go past the first step.

https://www.dropbox.com/s/c32ti5iare4ipfe/Screenshot%202017-10-30%2011.33.25.png?dl=0

class AppSSChat extends Component {

 render() {
     
     return (
          
            <ChatBot
            
              steps={[
                {
                  id: "1",
                  message: "What number I am thinking?",
                  trigger: "2"
                },
                {
                  id: "2",
                  options: [
                    { value: 1, label: "Number 1", trigger: "4" },
                    { value: 2, label: "Number 2", trigger: "3" },
                    { value: 3, label: "Number 3", trigger: "3" }
                  ]
                },
                {
                  id: "3",
                  message: "Wrong answer, try again.",
                  trigger: "2"
                },
                {
                  id: "4",
                  message: "Awesome! You are a telepath!",
                  end: true
                }
              ]}
            />
        
          );
  }
}

export default AppSSChat;

I am loading this via a router, (react-router-dom).

There are no errors in the console or anything??

โ”œโ”€ [email protected]
โ””โ”€ [email protected]

Behaviour of custom components that receive user inp

First of all, great work on this wonderful library. Iโ€™m using custom component to receive user input ( date using date widget, file upload etc.). In all these cases after receiving the input it would be really awesome if there was some capability to render them as user bubble (so that it feels more natural). I would remove the rendering of my custom component after receiving the correct input and can render a user input bubble or some how pipe that information through the props.

Trigger function user input, return find to next step using async/await

Dear Lucas,
I have idea so.
When user input, trigger function process return other value in next steps.
Example:

const steps = [
  {
    id: '0',
    message: 'Welcome to react chatbot!',
    trigger: '1',
  },{
    id: '1',
    user: true,

    trigger: async ({value, steps}) => await hello({value, steps}), // return 'hello' or 'thanks'

  }, {
    id: 'hello',
    message: 'Bye'
  }, {
    id: 'thanks',
    message: 'Thanks',
  }
];

[Error] Converting circular structure to JSON

Thanks for the inclusion of the cache prop. There is one issue though cache prop with custom components.

Whenever using custom components you will get an error 'Converting circular structure to JSON', tried it on all examples with custom components and got same error
chat
,

href links within messages?

when I pass an http href inside the text box the chabot does not recognize it as a link! How do I enable the chat to recognize links?

Chatbot goes through steps without pausing for user input

Hello,

I npm installed react-simple-chatbot --save
Then i imported to file with:

import ChatBot from 'react-simple-chatbot';

Here is where I define steps and invoke ChatBot:

render() {
const steps = [
{id:'0',
message:'Welcome to Single-ServingTech. I am a chatbot. What are you?',
trigger:'1'},
{id:'1',
message:'Oh Cmon be nice for chat sake'}
]

return(

    </div>
  </div>
);}

The chatbot loads and prints out the steps, but I am unable to enter any input after it finishes going through steps. It does not wait for user input before going from step 1 to step 2.

If you tell me a bit about how this is supposed to work, in your code, then I'd like to work on a solution.

according to package.json: "react": "^15.5.4"

Dynamic steps

Hi.

It's not clear to me after having a look to the example how to work with dynamic steps (i.e. steps returned from a remote service)?

Is it possible?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.