Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including robota with all npm packages installed. Try it out:

var robota = require("robota")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

robota v0.2.0

Easily write your own personal Cisco Spark bot(s)


Use Cisco Spark to provide robota.

Exposes extremely low-effort mechanism(s) for implementing personal bot slave(s).

Basic Usage

npm install --save robota; node -p 'require("robota")' # or: robota/es{5,6}

Provides a simple factory method, listen, which returns a Promise for a Bot.

The class Bot can #consumeAny Spark resource:event. (see details below)

In the future, it will likely make sense to support a plug-in Bot system.

class Bot

The constructor currently requires that credentials.access_token is passed.

const credentials = { access_token: process.env.CISCOSPARK_ACCESS_TOKEN }
const [name, secret, targetUrl] = [...] // webhook set-up prior to listening
new Bot(credentials).listenWebhook({ name, secret, targetUrl }, process.env.PORT)
  • #listenWebhook(webhook, ...args): Promises HTTP Server#listen(...args)

Additional webhook properties include event/resource and filter, etc.

  • #consumeAny(eventName, handler): easy to register handler(s); for example:
const credentials = { ... } // have to provide access_token (for Spark bot)
const webhook = { ... } // required: name, targetUrl; optional: secret, etc.
listen({ spark: { credentials, webhook } }, process.env.PORT).then((bot) => {
    bot.consumeAny('messages:created', function * echoDirectedMessage (spark) {
        if ('')) return
        const message = yield
        yield // will pick roomId, text

Integration Notes

P.S. The config module is awesome.

It can map process.env entities and may simplify many large configurations.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free