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

elica.js

v0.2.2

Published

SDK for elica-bot

Downloads

5

Readme

elica.js

Javascript SDK for building service module for elica.io

What is it?

elica.io is a extensible bot build using node.js and python. It provides a powerful paltform for developers to develop plugins for elica.io

How Elica works

Like all the chat bots, elica works by receiving messages from chat providers and provide response based on her configuration. One key difference for elica is elica is not designed to be human-like (that's google/microsoft's job), elica is designed to be useful so when you have something to ask, she will respond based on the available services configured for her.

How services works

Services in elica is a webserver that is able to host service configuration readable by elica and endpoint that can process messages posted by elica's main server. When a message arrives, if a specific service is required to complete the response, it will query the appoporiate service and send the response back to the user.

What's in this SDK?

Odds and ends, but mainly just a bot class that you will be able to hook up your own configuration and a middleware that is very simple to use.

Install

npm i elica.js -S

Usage

import Express				from 'express';
import Elica                            from 'elica.js';

const app = express(); // Create an express.js app

const bot = new Elica.Bot({
        intents: require('./intents.json'), // Define your intents
        triggers: require('./triggers.json'), // Define your triggers
        config: require('./config.json'), // Rest of your service config goes here
        routePrefix: '/weather', // Is your service prefixed a path
        key: process.env.API_KEY || 'apikey' // API key for your service
});

bot.intent('intent_name', intentHandler);

app.use(bot.handler.bind(bot)); // .bind() is essential

app.listen(3000, function () {
  console.log('Example app listening on port 3000!')
})

function intentHandler(correlationId, conversation, session, analysis, service) {
	return {
		response: ['Hello World'],
		conversation
	};
}

Elica.bot(config)

Creates a bot instance with your configs, having multiple bot instance in the same application is supported

  1. config (object)

    1. intents (array) array of your defined intents
    2. triggers (array) array of your triggers
    3. config (object) rest of configs for your service
    4. routePrefix (string) string if your service url is prefixed
    5. key (string) api key for your service
const bot = new Elica.Bot({
        intents: require('./intents.json'), // Define your intents
        triggers: require('./triggers.json'), // Define your triggers
        config: require('./config.json'), // Rest of your service config goes here
        routePrefix: '/weather', // Is your service prefixed a path
        key: process.env.API_KEY || 'apikey' // API key for your service
});

bot.intent(intentRegex, handler)

Define a handler for a specific intent name

  1. intentRegex (string) defined a regex matching one or multiple intent
  2. handler (function) a function that returns a promise resolve to the response of the service
bot.intent('intent_name', intentHandler);

bot.session(sessionType, handler)

Define a handler for a specific session type

  1. sessionType (string) matching one session type
  2. handler (function) a function that returns a promise resolve to the response of the service
bot.session('LOCATION', updateLocation);

bot.endpoints()

Return the auto configured endpoints for the service

bot.handler

A function that is used as a express middleware

Note If you forgot to use .bind(), you will get errors like 'Can not resolve XXX from undefined

app.use(bot.handler.bind(bot)); // .bind() is essential