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

0.1.8 • Public • Published

banner

Symon

npm-badge ci-badge license-badge typescript-badge

Minimalistic chatbot framework for humans.

Getting Started

Installation

npm install symon

Configuration

// English 
import { Bot } from 'symon';
const bot = new Bot();

// Other languages may require a specific stemmer:
// https://naturalnode.github.io/natural/stemmers.html
import { Bot, PorterStemmerUk as stemmer } from 'symon';
const bot = new Bot({ stemmer });

Natural Language Understanding

bot.addDocument({
  intent: 'chatter/greeting',
  examples: ['hello', 'hi'],
  answers: ['Hello!'],
});

bot.addDocument({
  intent: 'chatter/parting',
  examples: ['goodbye', 'bye'],
  answers: ['Bye!'],
});

Named Entity Recognition

bot.addEntity({
  label: 'insult',
  options: ['stupid', 'silly'],
});

bot.addEntity({
  label: 'praise',
  options: ['smart', 'sweet'],
});

bot.addDocument({
  intent: 'chatter/insult',
  examples: ['you are %insult%', '%insult%'],
  answers: ['You make me sad...'],
});

bot.addDocument({
  intent: 'chatter/praise',
  examples: ['you are %praise%', '%insult%'],
  answers: ['Thanks!'],
});

Handlers

bot.addDocument({
  intent: 'random',
  examples: ['pick a random number', 'say a random number'],
  handler: async (ctx) => {
    const number = Math.floor(Math.random() * 5);
    await ctx.say({ answer: number.toString() });
  },
});

Middlewares

bot.addMiddleware(async (req, res) => {
  if (!res.answer) {
    res.answer = `Sorry, I don't understand you.`;
  }
});

Built-in Shell Interface

import { Shell } from 'symon';
const shell = new Shell({ bot });
shell.start();

License

Symon is licensed under the MIT license.

Package Sidebar

Install

npm i symon

Weekly Downloads

9

Version

0.1.8

License

MIT

Unpacked Size

93.7 kB

Total Files

24

Last publish

Collaborators

  • sweetpalma