# simple-node-chatbot

> Simple JSON Chatbot

Latest version **1.0.7** (published 2020-08-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install simple-node-chatbot
pnpm add simple-node-chatbot
yarn add simple-node-chatbot
bun add simple-node-chatbot
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2020-08-07 |
| First published | 2020-04-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Vishal Chauhan |
| Maintainers | vishal.chauhan |
| Keywords | chatbot, json chatbot, structure chatbot |

## Links

- npm: https://www.npmjs.com/package/simple-node-chatbot
- Repository: https://github.com/vishalchauhan22/node-chat-bot
- Homepage: https://github.com/vishalchauhan22/node-chat-bot#readme
- Issues: https://github.com/vishalchauhan22/node-chat-bot/issues
- npm.io page: https://npm.io/package/simple-node-chatbot

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.7 (latest) — 2020-08-07
- 1.0.6 — 2020-08-07
- 1.0.5 — 2020-08-07
- 1.0.4 — 2020-08-07
- 1.0.3 — 2020-08-07
- 1.0.2 — 2020-08-06
- 1.0.1 — 2020-08-06
- 1.0.0 — 2020-04-20

## README

# Simple Node ChatBot

This module allows you to create your very first chatbot that run on you designed chat flow in a simplest way.

Step 1. create the structured chat flow, i.e the conversation flow, purely in a JSON format, but as a module in javascript.
That's it. you are good to test the bot.


![alt text](https://raw.githubusercontent.com/vishalchauhan22/node-chat-bot/master/examples/public/demo.gif "Demo")


## Configurations
  `chatflow.js`
![alt text](https://raw.githubusercontent.com/vishalchauhan22/node-chat-bot/master/examples/public/chatflow.png "Demo")

## How To use:

Refer the example directory to checkout how this works.

`server.js`
```
let SimpleChatBot = require('simple-node-chatbot');
let socketIo = require("socket.io");
let express = require('express');
let app = express();

let usersTable = {};

let dbService = {
    saveUser : (data)=>{
        return new Promise((resolve, reject)=>{
            usersTable[data.from] = data;
            return resolve(usersTable[data.from]);
        })
    },
    getUser : (from)=>{
        return new Promise((resolve, reject)=>{
            return resolve(usersTable[from]);
        })
    },
    updateUser : (from, data)=>{
        return new Promise((resolve, reject)=>{
            usersTable[from].next_flow = data.next_flow;
            return resolve(usersTable[from]);
        })
    }
}

app.use('/', express.static(__dirname+'/public'))
const server = require('http').createServer(app).listen(4000);
let io = socketIo(server);

simpleChatBot = new SimpleChatBot({
    chatFlow: require('./chatflow.js'),
    welcomeFlow: "onboarding",
    dbService: dbService,
    socket: io
})
```

## Applications:
The best use of this bot is to drive a structrured conversation or to answer frequjestly asked questions.


### Features planned:

1. Send multiple message as a response
2. Make use of user input to derive the output response message by using a hashmap (one-of) (key-value)


#### Below is the architecture that the bot follows.

<br>

![alt text](https://raw.githubusercontent.com/vishalchauhan22/node-chat-bot/master/examples/public/flow.jpg "Chatflow")

---
_Source: https://npm.io/package/simple-node-chatbot · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
