ozochat
TypeScript icon, indicating that this package has built-in type declarations

2.1.2 • Public • Published

Ozo

This doc is out of date and will be updated very soon. Major release v2.0 changed a lot of things.

The Super Simple Minimalistic Low-Functionality Chat Bot Application Programming Interface

Installation

npm install ozochat

Scripts

  • npm run dev - nodemon build & run

Usage

Import the Ozo class, and create a new Ozo object with the chat bot's name as the first argument.

node.js

  const Ozo = require('ozochat');
  const ozo = new Ozo.default("Matthew"); // if no args passed, name will be 'Ozo'. Second argument is a config, will explain later in detail

Chat with Ozo

To actually chat with Ozo, use the chat() method.

let response = ozo.chat("Hi ozo. How are you?"); // returns ChatMessage object

The above code will return a ChatMessage object.

ChatMessage object

The ChatMessage object includes everything you need to know about either a chat to Ozo, or from Ozo. The string sent via chat() gets converted into a ChatMessage object. The return value from chat() (Ozo's response) is a ChatMessage object.

interface ChatMessage {
  message: string, // Input/response string
  type?: number[], // The nature of the message (e.g question, greeting, etc)
}

Example

Here is a common example where Ozo can be used.

const Ozo = require('ozochat');
const ozo = new Ozo.default("Helper");

ozo.addIntent("forgotPassword"); // Create a new question type

// Add a list of phrases that will trigger our new question type
ozo.addEntities("forgotPassword", [ 
  "I forgot my password", "forgot password", "password forgotten", "forget pass", "forgot my pass",
  ...
]);

// Add a list of responses that will respond to our new question type
let forgotPasswordURL = 'www.mywebsite.com/forgotpass';
ozo.addResponse("forgotPassword", [
  `Shucks, that sucks. Let me point you in the right direction. Click here -> ${forgotPasswordURL}`
  ...
]);

An easier and much more maintainable example would be to split the chat types, phrases and responses into their own config files.

import { ChatTypes, ChatPhrases, ChatResponses } from './ozo.config';

const Ozo = require('ozochat');
const ozo = new Ozo("Quiz Master");

ozo.loadTypes(ChatTypes);
ozo.loadPhrases(ChatPhrases);
ozo.loadResponses(ChatResponses);
// or
ozo.loadConfig(ChatTypes, ChatPhrases, ChatResponses);

Readme

Keywords

none

Package Sidebar

Install

npm i ozochat

Weekly Downloads

1

Version

2.1.2

License

ISC

Unpacked Size

18.7 kB

Total Files

5

Last publish

Collaborators

  • mattl019