1.5.0 • Published 3 years ago

chat-moduler v1.5.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

chat-moduler

A conversation tool in Javascript based in modules.

About the project

Chat-Moduler is an multilingual, context-aware, open-source chatbot built on the idea of being entirely modular. It gives you the freedom of implementing your module logic and returning the data in whatever structure best suits your application, ready to receive a string (the user input), route it to the appropriate modules based on the words or expressions found, and returning a valid response. It is currently in early development.

Getting Started

npm i chat-moduler

or with yarn

yarn add chat-moduler

Usage

Call the module loader:

import { initialize } from "chat-moduler";

initialize([myCustomModule, otherModule], ["en-US", "pt-BR"]);

If the language array is not provided, en-US will always be used as default. At least one module must be provided to the modules array.

Call the chat engine:

import { chat } from "chat-moduler";

chat({ data: "Hola!", lang: "es-ES" });

If the language, en-US will always be used as default.

Modules

All Modules are simple Javascript objects with name, expressions, and the module itself, a function that will receive as argument an object with three properties: lang, context, and expression, and return the expected response with no specific format.

  • lang: the language currently used by the user, such as "en-US" or "pt-BR"
  • context: an array of previous user inputs
  • expression: the word or expression input by the user that was recognized by the module
const MyModule = {
    name: "myCustomModule",
    expressions: {
        "en-US": ["hi", "hey", "how are you"],
        "pt-BR": ["oi", "ola", "como vai"],
    },
    module: ({ expression, lang, context }) => {
        // YOUR LOGIC HERE
        return desiredResponse;
    }
};

Make sure the name of the module is unique. The expressions should always be provided without diacritics. These are the words or expressions input by the user that should fallback into this module. Inside the module, you are free to implement whatever logic suits best your application and return the data format desired.

Roadmap

  • Better Typescript support;
  • Improve the expression-matching logic;

Contributing

I am accepting contributions. Any contributions you make, be it bug fixes or new features, are greatly appreciated.

License

Distributed under the ISC License.

Contact

1.5.0

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago