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

calamars

v0.17.6

Published

proto-framework

Downloads

31

Readme

calamars

npm version Build Status Dependency Status coveralls License see all badges…

An alpha quality, under heavy development, proto-frramework for building chat applications.

Install

npm install --save calamars

Documentation

See the Library Reference for full documentation.

Overview

Calamars is a toolset of different libs that helps on common tasks of a conversational application development, such as:

  • bot daemon setup
  • question/answer routing
  • interaction with cloud-based natural language message parsers (LUIS, wit.ai).

Below are some usage examples of the different pieces of the calamars framework. For more use cases check the documentation or the test folder.

Facebook Messenger Bot Wrapper

basic echo bot

const FacebookMessengerBot = require('calamars').FacebookMessengerBot;

const myPageToken = 'EAASxZBKlWU...SwZDZD';
const myVerifyToken = 'RMHFOBtOd...X91LBu';
const myCallbackPath = '/webhook';
const myPort = 9091;

const myMessageListener = function(updateEvent){
    console.log('received message:', updateEvent.update.message.text);
    // reply with the same received message
    updateEvent.bot.sendMessage({
        userId: updateEvent.update.sender.id,
        text: updateEvent.update.message.text
    })
};

const mybot = new FacebookMessengerBot({
    port: myPort,
    callbackPath: myCallbackPath,
    verifyToken: myVerifyToken,
    pageTokens: [myPageToken],
    listeners: {
        onMessage: myMessageListener
    }
});

mybot.start().then(function(){
    console.log(`server is running on port ${myPort}`);
})

Check the Tutorial for a detailed guide of how to set up a Facebook App, a Facebook Page and how to install and run the example above.

For details on the available methods and implementation please refer to the FacebookMessengerBot class.

Chat replies Routing

string → string

import { createRouter } from 'calamars';
const routes = [
    ['yes', 'no'],
    ['stop', 'go go go'],
    ['goodbye', 'hello'],
    ['high', 'low'],
    ['why', 'I don’t know']
];
const router = createRouter(routes);

console.log(router('goodbye')); // hello

string → callback → string

import { createRouter } from 'calamars';
const callbacks = {
    yes() { return 'no'; },
    halt() { return 'go go go'; },
    goodbye() { return 'hello'; },
    high() { return 'low'; },
    why() { return 'I don’t know'; }
};
const routes = [
    ['yes', callbacks.yes],
    ['stop', callbacks.halt],
    ['goodbye', callbacks.goodbye],
    ['high', callbacks.high],
    ['why', callbacks.why]
];
const router = createRouter(routes);

console.log(router('goodbye')); // hello

echo any string input

import { createRouter } from 'calamars';

const routes = [
    [/.*/, matches => matches[0]]
];
const router = createRouter(routes);

console.log(router('goodbye')); // goodbye

string → LUIS → intentName → callback → string

import { LuisDriver, createRouter } from 'calamars';

const luis = new LuisDriver(options);
const callback = () => 'go go go';
const routes = [
    ['goodbye', callback]
];
const router = createRouter(routes);

luis.query('Good Bye!')
    .then(({ topScoringIntent }) => {
        const intentName = topScoringIntent.intent;

        console.log(router(intentName)); // 'go go go'
    });

More usage examples

Patches are welcome

If you want to help us improve this library with a fix, a feature, better documentation or any other thing, please refer to the contributing guide.

Showcase

Who is using calamars in the real world:

  • Calamarcopollo: an open-source Telegram/Facebook Messenger bot that searches for brazilian intercity bus schedules and tickets using natural language (powered by wit.ai and clickbus api).

If you are using it or know of someone else using it please let us know, open a pull request expanding this list, or file an issue :)

License