# robota

> Easily write your own personal Cisco Spark bot(s)

Latest version **0.2.0** (published 2017-01-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install robota
pnpm add robota
yarn add robota
bun add robota
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2017-01-29 |
| First published | 2017-01-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+11 in 2 direct dependencies) |
| Install scripts | no |
| Author | Tor E Hagemann |
| Maintainers | teh |
| Keywords | Cisco, Spark, Bot, Framework |

## Links

- npm: https://www.npmjs.com/package/robota
- Repository: https://github.com/hagemt/node-robota
- Homepage: https://github.com/hagemt/node-robota#readme
- Issues: https://github.com/hagemt/node-robota/issues
- npm.io page: https://npm.io/package/robota

## Dependencies (5)

- [bunyan](https://npm.io/package/bunyan.md) 1.8.5
- [config](https://npm.io/package/config.md) 1.24.0
- [lodash](https://npm.io/package/lodash.md) 4.17.4
- [co-body](https://npm.io/package/co-body.md) 4.2.0
- [request](https://npm.io/package/request.md) 2.79.0

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads
- [@modern-js/plugin-swc](https://npm.io/package/@modern-js/plugin-swc.md) — 3.4K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2017-01-29

## README

# robota

Use Cisco Spark to provide [robota](https://en.wikipedia.org/wiki/Corv%C3%A9e).

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 (spark.webhook.data.personEmail.endsWith('@sparkbot.io')) return
		const message = yield spark.bot.messages.get(spark.webhook.data.id)
		yield spark.bot.messages.create(message) // will pick roomId, text
	})
})
```

## Integration Notes

P.S. The [`config`](https://www.npmjs.com/package/config) module is awesome.

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

---
_Source: https://npm.io/package/robota · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
