{"_id":"@channarith.kin/chatbot-js","_rev":"3-65d422c9132b9239f6539995d8421e12","name":"@channarith.kin/chatbot-js","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@channarith.kin/chatbot-js","version":"1.0.0","license":"MIT","_id":"@channarith.kin/chatbot-js@1.0.0","maintainers":[{"name":"channarith.kin","email":"mynameischannarith@gmail.com"}],"dist":{"shasum":"f5f191dfb65bf3e6393df2e1dae934a2d4dc4ea1","tarball":"https://registry.npmjs.org/@channarith.kin/chatbot-js/-/chatbot-js-1.0.0.tgz","fileCount":16,"integrity":"sha512-JcSMdIENhayXUx6MM3I67rT/FkX1y6rwiOLRbb6VbErtjU6yzf8xTwDfbfy2DUi9YUMmH4hpcum0L29YxquZUw==","signatures":[{"sig":"MEQCIGDbJwjsZ1yaDiwFR5lF2tV+ZSTDOgI6/xNHTYcEs3erAiAcAnBwmU10gLN7gbv28I2SrU8b4vREo6AQDk72IQbIDw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14405},"main":"index.js","scripts":{"start":"node server.js"},"_npmUser":{"name":"channarith.kin","email":"mynameischannarith@gmail.com"},"_npmVersion":"11.2.0","description":"Simple NLP chatbot engine with:","directories":{},"_nodeVersion":"22.14.0","dependencies":{"dotenv":"^17.3.1","express":"^5.2.1","natural":"^8.1.1","mongoose":"^9.3.1","ml-naivebayes":"^4.0.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/chatbot-js_1.0.0_1774620632981_0.09594310869741207","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@channarith.kin/chatbot-js","version":"1.0.1","license":"MIT","_id":"@channarith.kin/chatbot-js@1.0.1","maintainers":[{"name":"channarith.kin","email":"mynameischannarith@gmail.com"}],"dist":{"shasum":"7190ab1a8bd678dcaa61612be5d289446ec0f083","tarball":"https://registry.npmjs.org/@channarith.kin/chatbot-js/-/chatbot-js-1.0.1.tgz","fileCount":15,"integrity":"sha512-Qetehw3MxLwM3jcm627Zace/9jvzOAZg4f12A19ibGVR1qme1JfF1xQ7u/fgPThWQlkKg4a+gIgp4ZtXC0cFMg==","signatures":[{"sig":"MEUCIQDMrhqkGJhEI1SgiDYRvgEAm9pmbXDCNqvNYmp6xldiWwIgIuZCwHnq7XpXKyMlTsSsLmu0bhGb60gy0KN+Rn/fsYY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12588},"main":"index.js","scripts":{"start":"node server.js"},"_npmUser":{"name":"channarith.kin","email":"mynameischannarith@gmail.com"},"_npmVersion":"11.2.0","description":"Simple NLP chatbot engine with:","directories":{},"_nodeVersion":"22.14.0","dependencies":{"dotenv":"^17.3.1","express":"^5.2.1","natural":"^8.1.1","mongoose":"^9.3.1","ml-naivebayes":"^4.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/chatbot-js_1.0.1_1774681807055_0.3384946512873048","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@channarith.kin/chatbot-js","version":"1.0.2","main":"index.js","license":"MIT","dependencies":{"dotenv":"^17.3.1","express":"^5.2.1","ml-naivebayes":"^4.0.0","mongoose":"^9.3.1","natural":"^8.1.1"},"publishConfig":{"access":"public"},"_id":"@channarith.kin/chatbot-js@1.0.2","scripts":{"start":"node server.js"},"description":"A simple NLP chatbot engine featuring:","_nodeVersion":"22.14.0","_npmVersion":"11.2.0","dist":{"integrity":"sha512-j3tPpe7IXh4YyzOQ+hNNk1sAjd1tzTlZH+CU/WRoE4ucOdrNNyMsaoeEZkzOxq9MpMfHRWeTPlCDg91wxbOeWg==","shasum":"481cb390cbd827d5c5606efd39530ba2249dc82a","tarball":"https://registry.npmjs.org/@channarith.kin/chatbot-js/-/chatbot-js-1.0.2.tgz","fileCount":15,"unpackedSize":20036,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGtIz/2J5wgAgveUkQRTIje4dD1S03inqkxQnQdPgHRjAiBq1LJ+mHTIK1w1XkOxzQya5oN/FdA0A6ZsZ4NukNfVVg=="}]},"_npmUser":{"name":"channarith.kin","email":"mynameischannarith@gmail.com"},"directories":{},"maintainers":[{"name":"channarith.kin","email":"mynameischannarith@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/chatbot-js_1.0.2_1774690755763_0.6611468742518323"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-27T14:10:32.903Z","modified":"2026-03-28T09:39:16.375Z","1.0.0":"2026-03-27T14:10:33.121Z","1.0.1":"2026-03-28T07:10:07.203Z","1.0.2":"2026-03-28T09:39:15.944Z"},"license":"MIT","description":"A simple NLP chatbot engine featuring:","maintainers":[{"name":"channarith.kin","email":"mynameischannarith@gmail.com"}],"readme":"# Chatbot-js\r\n\r\nA simple NLP chatbot engine featuring:\r\n\r\n- 📊 Dataset management\r\n- 🤖 Model prediction\r\n- 🗄️ MongoDB storage\r\n\r\n---\r\n\r\n## 📦 Installation\r\n\r\n```bash\r\nnpm install @channarith.kin/chatbot-js\r\n```\r\n\r\n## 🚀 Usage\r\n\r\n```js\r\nconst mongoose = require(\"mongoose\");\r\nconst chatbot = require(\"@channarith.kin/chatbot-js\");\r\n\r\n// 🔌 **Connect to MongoDB**\r\nawait mongoose.connect(YOUR_MONGO_CONNECTION_STRING);\r\n\r\n// ⚙️ **Initialize chatbot engine**\r\nconst engine = chatbot(mongoose, {\r\n  modelPath: \"ai\", // 📁 Directory where the model will be generated\r\n  threshold: 0.05, // 🎯 Confidence threshold (default: 0.04)\r\n  fallbackMessages: [\r\n    \"Sorry, I am not able to answer that yet. Could you please rephrase?\",\r\n    \"Oops! I don't understand this yet. Please help rephrase?\",\r\n  ], // 💬 Messages used when confidence is too low\r\n});\r\n\r\n// 🌐 **Expose API routes for dataset management**\r\napp.use(\"/api/chat-bot\", engine.routes); // Not recommend to expose to production, In development environment only.\r\n\r\n// **service to invoke internally\r\nconst { predictionService } = engine;\r\nresponse = await predictionService.chat(\"hi\");\r\n\r\n**console.log(response);**\r\n//  {\r\n//      reply: 'Hello!',\r\n//      intent: 'greeting',\r\n//      confidence: [\r\n//          { label: 'greeting', value: 0.07499999999999998 },\r\n//          { label: 'weather', value: 0.025 },\r\n//          { label: 'joke', value: 0.025 },\r\n//          { label: 'thanks', value: 0.024999999999999998 },\r\n//          { label: 'goodbye', value: 0.024999999999999994 }\r\n//      ]\r\n//  }\r\n```\r\n\r\n## Inside engine.routes\r\n\r\n```text\r\nrouter.use(\"/dataset\", datasetRoute(services.dataset)); // 📊 Manage training dataset\r\nrouter.use(\"/train\", trainRoute(services.train));       // 🧠 Train the chatbot model\r\nrouter.use(\"/chat\", chatRoute(services.prediction));    // 💬 Chat / get predictions\r\n```\r\n\r\n## 📊 Dataset API\r\n\r\nManage your chatbot training data.\r\n\r\n### 🔗 Endpoint\r\n\r\n`/api/chat-bot/dataset`\r\n\r\n---\r\n\r\n### 📥 GET /dataset\r\n\r\nGet all dataset entries\r\n\r\n```json\r\n// ✅ Response\r\n{\r\n  \"success\": true,\r\n  \"message\": \"Success\",\r\n  \"data\": [\r\n    {\r\n      \"_id\": \"69c542dfaa476ac3e2519987\",\r\n      \"intent\": \"greeting\",\r\n      \"questions\": [\r\n        \"hi\",\r\n        \"hello\",\r\n        \"hey\",\r\n        \"good morning\",\r\n        \"good afternoon\",\r\n        \"good evening\",\r\n        \"howdy\",\r\n        \"hi there\",\r\n        \"hello there\",\r\n        \"hey there\"\r\n      ],\r\n      \"answers\": [\"Hello!\", \"Hi there!\", \"Hey! How can I help you?\"],\r\n      \"createdAt\": \"2026-03-26T14:29:51.467Z\",\r\n      \"updatedAt\": \"2026-03-26T14:29:51.467Z\",\r\n      \"__v\": 0\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\n### ➕ POST /dataset\r\n\r\nCreate a new dataset entry\r\n\r\n```json\r\n// 📤 Request Body\r\n{\r\n  \"intent\": \"joke\",\r\n  \"questions\": [\r\n    \"tell me a joke\",\r\n    \"make me laugh\",\r\n    \"do you know a joke?\",\r\n    \"I want to hear a joke\",\r\n    \"can you tell me something funny?\",\r\n    \"funny joke please\",\r\n    \"say something funny\",\r\n    \"make me giggle\",\r\n    \"give me a joke\",\r\n    \"joke time\"\r\n  ],\r\n  \"answers\": [\r\n    \"Why did the computer go to the doctor? Because it caught a virus!\",\r\n    \"Why don’t scientists trust atoms? Because they make up everything!\",\r\n    \"I would tell you a joke about NaN, but you wouldn’t understand.\"\r\n  ]\r\n}\r\n// ✅ Response\r\n{\r\n    \"success\": true,\r\n    \"message\": \"Created successfully\",\r\n    \"data\": {\r\n        \"_id\": \"69c54329aa476ac3e2519992\",\r\n        \"intent\": \"weather\",\r\n        \"questions\": [\r\n            \"what's the weather today?\",\r\n            \"how is the weather today?\",\r\n            \"tell me the weather\",\r\n            \"is it raining today?\",\r\n            \"will it rain today?\",\r\n            \"do I need an umbrella?\",\r\n            \"is it sunny today?\",\r\n            \"what is the temperature today?\",\r\n            \"is it hot outside?\",\r\n            \"is it cold outside?\",\r\n            \"what's the forecast for today?\",\r\n            \"do I need a jacket today?\",\r\n            \"will it snow today?\",\r\n            \"is it windy today?\",\r\n            \"what's the weather like right now?\",\r\n            \"is the weather nice today?\",\r\n            \"how's the weather outside?\"\r\n        ],\r\n        \"answers\": [\r\n            \"I can't check live weather, but you can try a weather app.\",\r\n            \"Looks like you’ll need to check a weather website!\",\r\n            \"I’m not sure about the weather today, try checking an online forecast.\",\r\n            \"I don’t have live weather info, but it’s always good to carry an umbrella just in case!\"\r\n        ],\r\n        \"createdAt\": \"2026-03-26T14:31:05.307Z\",\r\n        \"updatedAt\": \"2026-03-28T09:08:38.731Z\",\r\n        \"__v\": 0\r\n    }\r\n}\r\n```\r\n\r\n### ✏️ PUT /dataset/:intent\r\n\r\nUpdate an existing dataset entry by intent\r\n\r\n```json\r\n// 📤 Request Body\r\n{\r\n  \"intent\": \"joke\",\r\n  \"questions\": [\r\n    \"tell me a joke\",\r\n    \"make me laugh\",\r\n    \"do you know a joke?\",\r\n    \"I want to hear a joke\",\r\n    \"can you tell me something funny?\",\r\n    \"funny joke please\",\r\n    \"say something funny\",\r\n    \"make me giggle\",\r\n    \"give me a joke\",\r\n    \"joke time\"\r\n  ],\r\n  \"answers\": [\r\n    \"Why did the computer go to the doctor? Because it caught a virus!\",\r\n    \"Why don’t scientists trust atoms? Because they make up everything!\",\r\n    \"I would tell you a joke about NaN, but you wouldn’t understand.\"\r\n  ]\r\n}\r\n// ✅ Response\r\n{\r\n    \"success\": true,\r\n    \"message\": \"Updated successfully\",\r\n    \"data\": {\r\n        \"_id\": \"69c54329aa476ac3e2519992\",\r\n        \"intent\": \"weather\",\r\n        \"questions\": [\r\n            \"what's the weather today?\",\r\n            \"how is the weather today?\",\r\n            \"tell me the weather\",\r\n            \"is it raining today?\",\r\n            \"will it rain today?\",\r\n            \"do I need an umbrella?\",\r\n            \"is it sunny today?\",\r\n            \"what is the temperature today?\",\r\n            \"is it hot outside?\",\r\n            \"is it cold outside?\",\r\n            \"what's the forecast for today?\",\r\n            \"do I need a jacket today?\",\r\n            \"will it snow today?\",\r\n            \"is it windy today?\",\r\n            \"what's the weather like right now?\",\r\n            \"is the weather nice today?\",\r\n            \"how's the weather outside?\"\r\n        ],\r\n        \"answers\": [\r\n            \"I can't check live weather, but you can try a weather app.\",\r\n            \"Looks like you’ll need to check a weather website!\",\r\n            \"I’m not sure about the weather today, try checking an online forecast.\",\r\n            \"I don’t have live weather info, but it’s always good to carry an umbrella just in case!\"\r\n        ],\r\n        \"createdAt\": \"2026-03-26T14:31:05.307Z\",\r\n        \"updatedAt\": \"2026-03-28T09:08:38.731Z\",\r\n        \"__v\": 0\r\n    }\r\n}\r\n```\r\n\r\n### ❌ DELETE /dataset/:intent\r\n\r\nDelete a dataset entry by intent\r\n\r\n```json\r\n// ✅ Response\r\n{\r\n  \"success\": true,\r\n  \"message\": \"Deleted successfully\"\r\n}\r\n```\r\n\r\n## 🧠 Train API\r\n\r\nManage your chatbot training data.\r\n\r\n---\r\n\r\n### ➕ POST /train\r\n\r\nInvoke to train function and create new model based on config modelPath\r\n\r\n```json\r\n// ✅ Response\r\n{\r\n  \"success\": true,\r\n  \"message\": \"Model trained successfully\",\r\n  \"data\": {\r\n    \"message\": \"Model trained successfully\",\r\n    \"accuracy\": 82.35,\r\n    \"totalData\": 57,\r\n    \"trainSize\": 40,\r\n    \"testSize\": 17,\r\n    \"correct\": 14\r\n  }\r\n}\r\n```\r\n\r\n### 💬 Chat API\r\n\r\nManage your chatbot training data.\r\n\r\n---\r\n\r\n### ➕ POST /chat\r\n\r\nFor testing the chat, for developer only\r\n\r\n```json\r\n// 📤 Request Body\r\n{\r\n   \"message\": \"what is the weather today?\"\r\n}\r\n\r\n// ✅ Response\r\n{\r\n    \"success\": true,\r\n    \"message\": \"Success\",\r\n    \"data\": {\r\n        \"reply\": \"I’m not sure about the weather today, try checking an online forecast.\",\r\n        \"intent\": \"weather\"\r\n    }\r\n}\r\n```\r\n","readmeFilename":"README.md"}