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

chatbotbase

v1.0.3

Published

A modular node.js framework to write chatbots for different platforms like Google Home and Amazon Alexa at once.

Downloads

46

Readme

ChatbotBase

A modular node.js framework to write chatbots for different platforms like Google Home and Amazon Alexa at once.

NPM Version NPM Downloads

Usage

In order to use this library you need to install the chatbotbase module and of cause the platforms you want to support. Currently are the following platforms supported:

If you want to support both platforms use this commands:

npm init
npm install chatbotbase chatbotbase-dialogflowplatform chatbotbase-alexaplatform

The next Step is to write your own chatbot by extending the VoiceAssistant class. The most important methods are:

  • loadPlatforms(), there you define the platforms you actually want to support
  • reply() where you get the input from the user and you return your answer
  • loadTranslations() where you define your translations
  • optional loadTracker() if you want to track the input of the user e.g. with chatbase

Basic example

Here is the full TypeScript code to write a skill/action supporting Alexa and the Google Assistant. This example welcomes you with a random phrase and gives the user the suggestion to say bye (on supported platforms here just Google Assistant). This example supports multiple languages here German and English.

import {Input, Output, VoiceAssistant, VoicePlatform, Translations} from 'chatbotbase';
import {Dialogflow} from 'chatbotbase-dialogflowplatform';
import {Alexa} from 'chatbotbase-alexaplatform';

export class MyChatBot extends VoiceAssistant {
    loadPlatforms(): VoicePlatform[] {
        return [new Dialogflow(), new Alexa()];
    }

    reply(input: Input): Output {
        const reply = input.reply();
        switch(input.intent) {
        case 'LaunchRequest':
        case 'Default Welcome Intent':
            reply.addReply(this.plainReply(this.t('WELCOME')));
            reply.addSuggestion(this.suggestion(this.t('BYE')));
            reply.setExpectAnswer(true);
            break;
        case 'Exit':
        case 'SessionEndedRequest':
            reply.addReply(this.plainReply(this.t('STOP_MESSAGE')));
            break;
        }
        return reply;
    }

    loadTranslations(): Translations {
        return {
            'de': {
                WELCOME: ['Hi', 'Hallo'],
                STOP_MESSAGE: ['Aufwiedersehen!', 'Bis bald.'],
                BYE: 'Tschüss'
            },
            'en': {
                WELCOME: ['Hi', 'Hello'],
                STOP_MESSAGE: ['Good bye!', 'See you soon.'],
                BYE: 'Bye'
            }
        };
    }
}

Tracking

The ChatbotBase also allows you to track the input of the user e.g. with chatbase. To use just just import the chatbaseplugin and overwrite the loadTracker() method like this:

loadTracker(): TrackingProvider[] {
    return [new Chatbase('<your-api-key>', '<your-app-version>')];
}

Currently there are implementation the following tracker:

ToDos

  • Tests
  • Coverage
  • Wiki how to create own platforms/tracking provider
  • Integration of Konversation

License

Apache 2.0