npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

csml-engine

v0.0.19

Published

CSML engine for nodejs

Downloads

4

Readme

CSML Conversational Engine for nodejs

This package allows you to create CSML chatbots and use them in your own nodejs projects.

CSML is a programming language dedicated to create rich conversational experiences on any chat interface. It helps with defining conversational logic, handling user context, long-term and short-term memory, and integrating with third-party APIs.

For more information about CSML, visit https://csml.dev.

Requirements

In order to use CSML in your program, you will need a MongoDB database. The credentials are loaded from your environment. Please use the .env.example file in this repository as a reference.

Other environment variables are also available:

  • DISABLE_SSL_VERIFY=true|false: by default, CSML does not allow invalid (or self-signed) SSL certificates. By setting this to false, you can accept unsafe SSL certificates. Defaults to true.
  • ENCRYPTION_SECRET=my_&ncrypti0nS3cr3t!: any string to use as your own encryption key for storing sensitive data safely. If left empty, data will not be encrypted upon storing in the database. Defaults to none.
  • DEBUG=true|false: print debug information in console. Defaults to false.

Installation

This projects runs on macOS and linux (ubuntu, debian) out of the box, with nodejs 12.x (lts) and 14.x (latest):

npm install csml-engine

Then, in your project:

import csml from 'csml-engine';

// or
const csml = require('csml-engine');

Compiling from source

For use on other architectures, you will need to compile the project from source into a native node file compatible with your system:

Then, run the following command:

git clone https://github.com/CSML-by-Clevy/node-csml-engine.git
git submodule update --init --recursive
cd node-csml-engine
npm i

Under native/ you will find a index.node native node file that you can then easily import in your project like any other module:

import csml from './path/to/index.node';

// or
const csml = require('./path/to/index.node');

Usage

Read the documentation to find more informations about the various data formats used in this documentation.

Analyze an incoming event

csml.run(Bot, Event);

Returns:

{
  "request_id": "ec4f47ec-7c99-4b9c-99df-782956aa2cbc",
  "interaction_id": "0b87e25a-f6f4-4617-a10c-a3c725dca3d3",
  "client": {
    "bot_id": "0d1e4c9a-f51b-41bf-8996-e03d8cd44c87",
    "channel_id": "4b229bae-dd10-43b2-877f-7603dc02758d",
    "user_id": "some-user-id"
  },
  "conversation_end": true,
  "messages": [
    {
      "conversation_id": "545f788b-e44d-45ac-a585-93245064ba8d",
      "direction": "SEND",
      "interaction_order": 0,
      "payload": {
        "content": {
          "text": "Hello"
        },
        "content_type": "text"
      }
    }
  ],
  "received_at": "2020-06-09T06:41:37.740Z",
  "is_authorized": true
}

Validate whether a bot contains valid CSML

csml.validateBot(Bot);

Returns:

{
  "valid": false,
  "errors": [
    {
      "message": "Some error message",
      "flow": "name of flow",
      "step": "name of step",
      "line": 123,
      "column": 32
    }
    ...
  ],
  "warnings": [
    {
      "message": "Some warning message",
      "flow": "name of flow",
      "step": "name of step",
      "line": 123,
      "column": 32
    }
    ...
  ]
}

List all the steps in a given flow

csml.getFlowSteps(flow_content);

Find out whether a given client has an open conversation

csml.getOpenConversation(Client);

Returns:

{
  "has_open": true,
  "conversation": Conversation
}

Close any open conversation for a given client

csml.closeAllConversations(Client);