New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
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
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
0
Weekly downloads
 
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc