You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

symon

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

symon

Simple framework for building smart chatbots.

0.2.1
latest
Source
npmnpm
Version published
Maintainers
0
Created
Source

banner

Symon

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

🇬🇧 🇺🇦 🇩🇪 🇫🇷 🇪🇸 🇵🇹 🇮🇹 🇳🇱 🇳🇴 🇸🇪 🇮🇷 🇯🇵 🇮🇩 🇷🇺

Minimalistic chatbot framework for humans.

Getting Started

Installation

npm install symon

Configuration

import { Bot } from 'symon';
const bot = new Bot({
  languages: ['en'],
});

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

import { EnumEntity } from 'symon';

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

bot.addEntity(
  new EnumEntity{
    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() });
  },
});

Dialogues

bot.addDocument({
  intent: 'response/yes',
  examples: ['yes', 'yeah'],
});

bot.addDocument({
  intent: 'response/no',
  examples: ['no', 'nope'],
});

bot.addDocument({
  intent: 'suicide',
  examples: ['stop yourself', 'kill yourself'],
  handler: async (ctx) => {
    const { intent } = await ctx.classify(await ctx.ask({ answer: 'Really?' }));
    if (intent === 'response/yes') {
      process.exit(0);
    } else {
      await ctx.say({ answer: 'Hooray!' });
    }
  },
});

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();

Running examples

git clone https://github.com/sweetpalma/symon.git && cd symon && npm install
npm run example en
npm run example uk

License

Symon is licensed under the MIT license.

Keywords

chatbot

FAQs

Package last updated on 05 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts