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

crowdcurio-bot-builder

v1.2.1

Published

The CrowdCurio Bot Builder SDK provides the functionality necessary for building bots on the CrowdCurio platform. The primary purpose of the CrowdCurio Bot Builder SDK is to generalize the communication bridge between CrowdCurio and bot instances. The Cro

Downloads

41

Readme

The CrowdCurio Bot Builder SDK

The CrowdCurio Bot Builder SDK provides the functionality necessary for building bots on the CrowdCurio platform. The primary purpose of the CrowdCurio Bot Builder SDK is to generalize the communication bridge between CrowdCurio and bot instances. The CrowdCurio Bot Builder SDK is built around the Microsoft Bot Framework.

Installation

The SDK is available through NPM:

    npm install crowdcurio-bot-builder

The CrowdCurioBot Class

The CrowdCurio Bot Builder library provides the CrowdCurioBot class, a lightweight and inheritable class implementation that handles the burden of interfacing with CrowdCurio and otherwise writing a range of boilerplate code.

One major feature of the CrowdCurio class is that it automatically keeps track of conversational state (i.e., task, experiment, condition, and data). In order for this to occur, CrowdCurio must send a POST request to /api/context specifying the necessary relational attributes. For more information, refer to /lib/bot-builder.js.

As a by-product of keeping track of conversational state, the CrowdCurioBot class affords developers with the ability to easily track and manage user's interface state with two attributes in a given conversation: state and meta. The state attribute should be used to reflect the global state of a shared interface. The meta attribute should be used to collect meta-information about the shared information.

Using the CrowdCurio Bot Builder

The one and only use-case for the CrowdCurio Bot Builder is supplying the CrowdCurioBot class as an extendable component. Extensions should primarily occur for two reasons:

  1. Bot-specific dialog implementations.
  2. Bot-specific handling of the state and meta fields.

For example, the creation of a simple "Hello World!" bot might look like the following:

// file: timbot.js
const CrowdCurioBot = require('crowdcurio-bot-builder');

// create a new Bot class that extends the CrowdCurioBot class 
class TimBot extends CrowdCurioBot {

    constructor() {
        super(); // *note*: this must be called!
    }

     // return a promise to ensure we know when the bot is ready to go.
    init() {
         const that = this;
         return new Promise(((resolve, reject) => {
         that.initialize().then(() => {
         // define a simple dialog that always responds with a static message.
             that.bot.dialog('/', (session) => {
             session.send('Hello World! I wish I was a Timbit.');
             });

             // start listening for messages
             that.serve();
             resolve();
         });
         }).bind());
     }
}

module.exports = TimBot;

And in a separate file:

// file: app.js
require('dotenv'); // to read environment vars from '.env'
const TimBot = require('timbot.js');

function main(){
    let timbot = new TimBot({
         // General Bot Instantiation Info.
         name: 'Tim',
         env: process.env.BotEnv,

         // Azure DB Authentication
         azureDBLogin: {
         host: process.env.AZURE_DB_HOST,
         user: process.env.AZURE_DB_USER,
         password: process.env.AZURE_DB_PASSWORD,
         },

         // CrowdCurio Bot Authentication Info.
         crowdCurioLogin: {
         username: process.env.CROWDCURIO_USERNAME,
         password: process.env.CROWDCURIO_PASSWORD,
         },

         // Microsoft Bot App ID and Password
         appId: process.env.MICROSOFT_APP_ID,
         appPassword: process.env.MICROSOFT_APP_PASSWORD,
    });

    // initialize and print a message when ready.
    timbot.init().then(function(){
        console.log("We're ready to go!");
    });
}  

 // kick off the main function
main();

With these two files, we can start the application with:

npm install
node app.js

Note: A functional bot will print a message or two indicating that it is, in fact, listening for incoming messages. For practical testing, please use the Microsoft Bot Framework Emulator.

Local Development

The CrowdCurio Bot Builder SDK makes heavy use of the Microsoft Bot Framework's DirectLineAPI to directly interface with bot applications. The DirectLineAPI is statically coded with web URLs that must be used to interface with any bot applications.

If you wish to have the CrowdCurio system interface with a locally running version of your bot, you should use ngrok. The ngrok CLI can be installed via npm:

npm i -g ngrok

After installation, you can start the ngrok service to get a valid URL for your locally running bot application.

ngrok http 9000

Testing

The repository uses Mocha, Chai, and Istanbul for unit-testing and code coverage metrics. Tests can be executed with: npm test.

Contact

Please direct all questions or comments to Alex Williams.