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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@channarith.kin/chatbot-js

v1.0.2

Published

A simple NLP chatbot engine featuring:

Readme

Chatbot-js

A simple NLP chatbot engine featuring:

  • 📊 Dataset management
  • 🤖 Model prediction
  • 🗄️ MongoDB storage

📦 Installation

npm install @channarith.kin/chatbot-js

🚀 Usage

const mongoose = require("mongoose");
const chatbot = require("@channarith.kin/chatbot-js");

// 🔌 **Connect to MongoDB**
await mongoose.connect(YOUR_MONGO_CONNECTION_STRING);

// ⚙️ **Initialize chatbot engine**
const engine = chatbot(mongoose, {
  modelPath: "ai", // 📁 Directory where the model will be generated
  threshold: 0.05, // 🎯 Confidence threshold (default: 0.04)
  fallbackMessages: [
    "Sorry, I am not able to answer that yet. Could you please rephrase?",
    "Oops! I don't understand this yet. Please help rephrase?",
  ], // 💬 Messages used when confidence is too low
});

// 🌐 **Expose API routes for dataset management**
app.use("/api/chat-bot", engine.routes); // Not recommend to expose to production, In development environment only.

// **service to invoke internally
const { predictionService } = engine;
response = await predictionService.chat("hi");

**console.log(response);**
//  {
//      reply: 'Hello!',
//      intent: 'greeting',
//      confidence: [
//          { label: 'greeting', value: 0.07499999999999998 },
//          { label: 'weather', value: 0.025 },
//          { label: 'joke', value: 0.025 },
//          { label: 'thanks', value: 0.024999999999999998 },
//          { label: 'goodbye', value: 0.024999999999999994 }
//      ]
//  }

Inside engine.routes

router.use("/dataset", datasetRoute(services.dataset)); // 📊 Manage training dataset
router.use("/train", trainRoute(services.train));       // 🧠 Train the chatbot model
router.use("/chat", chatRoute(services.prediction));    // 💬 Chat / get predictions

📊 Dataset API

Manage your chatbot training data.

🔗 Endpoint

/api/chat-bot/dataset


📥 GET /dataset

Get all dataset entries

// ✅ Response
{
  "success": true,
  "message": "Success",
  "data": [
    {
      "_id": "69c542dfaa476ac3e2519987",
      "intent": "greeting",
      "questions": [
        "hi",
        "hello",
        "hey",
        "good morning",
        "good afternoon",
        "good evening",
        "howdy",
        "hi there",
        "hello there",
        "hey there"
      ],
      "answers": ["Hello!", "Hi there!", "Hey! How can I help you?"],
      "createdAt": "2026-03-26T14:29:51.467Z",
      "updatedAt": "2026-03-26T14:29:51.467Z",
      "__v": 0
    }
  ]
}

➕ POST /dataset

Create a new dataset entry

// 📤 Request Body
{
  "intent": "joke",
  "questions": [
    "tell me a joke",
    "make me laugh",
    "do you know a joke?",
    "I want to hear a joke",
    "can you tell me something funny?",
    "funny joke please",
    "say something funny",
    "make me giggle",
    "give me a joke",
    "joke time"
  ],
  "answers": [
    "Why did the computer go to the doctor? Because it caught a virus!",
    "Why don’t scientists trust atoms? Because they make up everything!",
    "I would tell you a joke about NaN, but you wouldn’t understand."
  ]
}
// ✅ Response
{
    "success": true,
    "message": "Created successfully",
    "data": {
        "_id": "69c54329aa476ac3e2519992",
        "intent": "weather",
        "questions": [
            "what's the weather today?",
            "how is the weather today?",
            "tell me the weather",
            "is it raining today?",
            "will it rain today?",
            "do I need an umbrella?",
            "is it sunny today?",
            "what is the temperature today?",
            "is it hot outside?",
            "is it cold outside?",
            "what's the forecast for today?",
            "do I need a jacket today?",
            "will it snow today?",
            "is it windy today?",
            "what's the weather like right now?",
            "is the weather nice today?",
            "how's the weather outside?"
        ],
        "answers": [
            "I can't check live weather, but you can try a weather app.",
            "Looks like you’ll need to check a weather website!",
            "I’m not sure about the weather today, try checking an online forecast.",
            "I don’t have live weather info, but it’s always good to carry an umbrella just in case!"
        ],
        "createdAt": "2026-03-26T14:31:05.307Z",
        "updatedAt": "2026-03-28T09:08:38.731Z",
        "__v": 0
    }
}

✏️ PUT /dataset/:intent

Update an existing dataset entry by intent

// 📤 Request Body
{
  "intent": "joke",
  "questions": [
    "tell me a joke",
    "make me laugh",
    "do you know a joke?",
    "I want to hear a joke",
    "can you tell me something funny?",
    "funny joke please",
    "say something funny",
    "make me giggle",
    "give me a joke",
    "joke time"
  ],
  "answers": [
    "Why did the computer go to the doctor? Because it caught a virus!",
    "Why don’t scientists trust atoms? Because they make up everything!",
    "I would tell you a joke about NaN, but you wouldn’t understand."
  ]
}
// ✅ Response
{
    "success": true,
    "message": "Updated successfully",
    "data": {
        "_id": "69c54329aa476ac3e2519992",
        "intent": "weather",
        "questions": [
            "what's the weather today?",
            "how is the weather today?",
            "tell me the weather",
            "is it raining today?",
            "will it rain today?",
            "do I need an umbrella?",
            "is it sunny today?",
            "what is the temperature today?",
            "is it hot outside?",
            "is it cold outside?",
            "what's the forecast for today?",
            "do I need a jacket today?",
            "will it snow today?",
            "is it windy today?",
            "what's the weather like right now?",
            "is the weather nice today?",
            "how's the weather outside?"
        ],
        "answers": [
            "I can't check live weather, but you can try a weather app.",
            "Looks like you’ll need to check a weather website!",
            "I’m not sure about the weather today, try checking an online forecast.",
            "I don’t have live weather info, but it’s always good to carry an umbrella just in case!"
        ],
        "createdAt": "2026-03-26T14:31:05.307Z",
        "updatedAt": "2026-03-28T09:08:38.731Z",
        "__v": 0
    }
}

❌ DELETE /dataset/:intent

Delete a dataset entry by intent

// ✅ Response
{
  "success": true,
  "message": "Deleted successfully"
}

🧠 Train API

Manage your chatbot training data.


➕ POST /train

Invoke to train function and create new model based on config modelPath

// ✅ Response
{
  "success": true,
  "message": "Model trained successfully",
  "data": {
    "message": "Model trained successfully",
    "accuracy": 82.35,
    "totalData": 57,
    "trainSize": 40,
    "testSize": 17,
    "correct": 14
  }
}

💬 Chat API

Manage your chatbot training data.


➕ POST /chat

For testing the chat, for developer only

// 📤 Request Body
{
   "message": "what is the weather today?"
}

// ✅ Response
{
    "success": true,
    "message": "Success",
    "data": {
        "reply": "I’m not sure about the weather today, try checking an online forecast.",
        "intent": "weather"
    }
}