shazi-chatter
v1.0.0
Published
A chatbot that can answer questions based on a given json dataset
Downloads
3
Readme
Shazibot
Shazibot is a Node module that generates responses based on a given input using a dataset.
Table of Contents
Installation
To install Shazibot, use the following command:
npm install shazibot
Usage
To use Shazibot, follow these steps:
Import the module:
const { generateResponse } = require("shazibot");
Define your input and dataset:
let input = "How are you?"; let dataset = { Hello: ["Hi", "Hello", "Hey"], "How are you?": ["I'm good", "I'm fine", "I'm okay"], Goodbye: ["Bye", "Goodbye", "See you later"], }; let unMatchedResponse = [ "I'm sorry, I don't understand", "I don't know", "Huh?", "Sorry, I didn't get that", "Can you repeat that?", ]; let defaultResponse = ["Hello"];
Generate a response using the
generateResponse
function:let response = generateResponse( input, dataset, unMatchedResponse, defaultResponse );
Print the response:
console.log(response);
API Reference
generateResponse(input, dataset, unMatchedResponse, defaultResponse)
This function generates a response based on the given input and dataset.
input
(string): The input for which a response needs to be generated.dataset
(object): The dataset containing input-response mappings.unMatchedResponse
(array): An array of responses to be used when no match is found in the dataset.defaultResponse
(array): An array of default responses to be used when the input is empty or undefined.
Returns the generated response.