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-native-simple-chatbot

v1.1.0

Published

A Simple react-native Chat Bot.

Downloads

20

Readme

ChatBot

A Simple react-native Chat Bot.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

What things you need to install the software:

Download and Install: Node

Once Node is installed, run

npm install react-native

Have an up and running react-native project. See https://facebook.github.io/react-native/docs/getting-started for more information.

Installing

To install component, navigate to project root directory and run

npm install react-native-simple-chatbot

Documentation

Props

| Name | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | ChatBotID | PropTypes.string | Yes | | Unique ID for the Chat Bot. | | questions | PropTypes.array | Yes | | Array for the Chat Bot questions. | | chatHeader | PropTypes.string | Yes | | Small text prior to asking questions. | | userIcon | PropTypes.object | Yes | | User Icon image source. | | cpuIcon | PropTypes.object | Yes | | CPU Icon image source. | | imagesArray | PropTypes.object | Yes | | Array of React.Component images | | ref | PropTypes.string | No | | Used for referencing in parent react-native js file. | | customComponentCallback | PropTypes.func | No | | Function to add and handle custom components. | | onChatEndCallback | PropTypes.func | No | | Function to handle chat completion. | | previousValue | PropTypes.object | No | | Variable to initialize chat. |

Steps

| Name | Type | Required | Description | | --- | --- | --- | --- | | id | string | Yes | Unique ID for step | | message | string | No | CPU message to the user. | | user | boolean | Yes | Boolean to determine wheter user input is required. | | multipleOptionsSelect | boolean | No | Boolean to determine if user can select multiple options. | | options | array | No | Array to hold options for user to select. | | slider | array | No | Array to hold options for the slider. | | custom | boolean | No | Boolean to determine if a custom component is used. | | customid | string | No | Unique ID for the custom component. | | trigger | string | Yes | Unique ID for the Chat Bot to determine next step. | | end | boolean | Yes | Boolean to determine end of chat. |

Options

| Name | Type | Required | Description | | --- | --- | --- | --- | | value | string | Yes | Value for choice. | | trigger | string | Yes | Unique ID for the Chat Bot to determine next step. | | imageU | string | No | Image id (from images.js) for unselected choice. | | imageS | string | No | Image id (from images.js) once user selects choice. |

Slider

| Name | Type | Required | Description | | --- | --- | --- | --- | | value | number | Yes | Value for choice. | | trigger | string | Yes | Unique ID for the Chat Bot to determine next step. | | marker | string | Yes | Value saved by ChatBot. |

Usage

Within react-native js file

import ChatBot from 'react-native-simple-chatbot';
import images from '.../images/images';

const ChatFile = require('../json/chatbot.json'); // Array from json file for chatbot

customComponents(customID) {
    if (customID === 'CustomID') {
        this.refs.handleCustomReturn('Some Text'); // Method to add Text to Chat Bot
        this.refs.addCustomToChatArray(<CustomComponent />); // Method to add a custom react-native component to Chat Bot
    }
}

<ChatBot
    ref="ChatBot"
    ChatBotID="ChatBot ID"
    questions={ChatFile.chatone} 
    chatHeader={(new Date()).toDateString()}
    customComponentCallback={this.customComponents.bind(this)}
    userIcon={images.UserIcon}
    cpuIcon={images.CPUIcon}
    imagesArray={images}
/>

Within json file

{
    "chatone": [
        {
            "id": "1",
            "message": "Hello. ",
            "user": "false",
            "options": [],
            "slider": [],
            "custom": "false",
            "customid": "",
            "trigger": "2",
            "end": "false"
        },
        {
            "id": "2",
            "message": "",
            "user": "true",
            "options": [],
            "slider": [],
            "custom": "false",
            "customid": "",
            "trigger": "3",
            "end": "false"
        },
        {
            "id": "3",
            "message": "",
            "user": "true",
            "multipleOptionsSelect": "false",
            "options": [
                {"value": "Yes", "trigger": "4","imageU": "", "imageS": ""},
                {"value": "No", "trigger": "4","imageU": "", "imageS": ""}
            ],
            "slider": [],
            "custom": "false",
            "customid": "",
            "trigger": "",
            "end": "false"
        },
        {
            "id": "4",
            "message": "",
            "user": "false",
            "options": [],
            "slider": [],
            "custom": "true",
            "customid": "CustomID",
            "trigger": "5",
            "end": "false"
        },
        {
            "id": "5",
            "message": "",
            "user": "true",
            "options": [],
            "slider": [
                {"value": "1", "trigger": "6", "marker": "None"},
                {"value": "2", "trigger": "6", "marker": "Little"},
                {"value": "3", "trigger": "6", "marker": "Somewhat"},
                {"value": "4", "trigger": "6", "marker": "A bit"},
                {"value": "5", "trigger": "6", "marker": "A lot"}
            ],
            "custom": "false",
            "customid": "",
            "trigger": "",
            "end": "false"
        },
        {
            "id": "6",
            "message": "Thank you.",
            "user": "false",
            "options": [],
            "slider": [],
            "custom": "false",
            "customid": "",
            "trigger": "",
            "end": "true"
        }
    ]
}

Within images.js

const images = {
    // Image for logo
    Logo: require('../images/Logo.png'),
    // Image for ChatBot Icons
    UserIcon: require("../images/user_icon.png"),
    CPUIcon: require("../images/cpu_Logo.png"),
};

export default images;

Built With

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Hamza Varvani - Initial work - HamzaKV

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Inspiration - https://github.com/FaridSafi/react-native-gifted-chat
  • Inspiration - https://github.com/LucasBassetti/react-simple-chatbot