Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flint-bot/sparky
Cisco Spark API for NodeJS (deprecated in favor of https://github.com/webex/webex-bot-node-framework)
https://github.com/flint-bot/sparky
cisco spark
Last synced: 12 days ago
JSON representation
Cisco Spark API for NodeJS (deprecated in favor of https://github.com/webex/webex-bot-node-framework)
- Host: GitHub
- URL: https://github.com/flint-bot/sparky
- Owner: flint-bot
- License: mit
- Created: 2016-03-28T04:27:26.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T17:31:27.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T13:11:13.526Z (7 months ago)
- Topics: cisco, spark
- Language: JavaScript
- Homepage:
- Size: 3.72 MB
- Stars: 17
- Watchers: 8
- Forks: 12
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-webex - sparky - A simple API wrapper for Node.js (by nmarus). (Client SDKs / REST API clients)
README
# node-sparky
[![NPM](https://nodei.co/npm/node-sparky.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/node-sparky/)
#### Cisco Spark API for Node JS
This is a Cisco Spark API Library for Node JS. This project aims to simplify interaction with the Spark API while transparently handling more complex operations such as pagination, webhook creation, and webhook authentication. If you have a question, feature request, or have found a bug, please open an issue.
#### Quick Start
```js
const Spark = require('node-sparky');const spark = new Spark({ token: '' });
spark.roomsGet(10)
.then(rooms => rooms.forEach(room => console.log(room.title)))
.catch(err => console.error(err));
```## Features
* [Rate limiting headers](https://developer.ciscospark.com/blog/blog-details-8193.html)
inspected to adjust request rates based on Cisco Spark API. These are
automatically re-queued and sent after the `retry-after` timer expires.
* File processor for retrieving attachments from room.
* Returns promises that comply with [A+ standards.](https://promisesaplus.com/).
* Handles pagination transparently. (Receive unlimited records)
* Support for [authenticated HMAC-SHA1 webhooks](https://developer.ciscospark.com/webhooks-explained.html#sensitive-data)## Using node-sparky as a Node JS Package
This module can be installed via NPM:
```bash
npm install node-sparky --save
```## Using node-sparky webhook event parser in an Express App
```js
const Spark = require('node-sparky');
const express = require('express');
const bodyParser = require('body-parser');
const when = require('when');const spark = new Spark({
token: '',
webhookSecret: 'somesecr3t',
});const port = parseInt(process.env.PORT || '3000', 10);
// add events
spark.on('messages-created', msg => console.log(`${msg.personEmail} said: ${msg.text}`));const app = express();
app.use(bodyParser.json());// add route for path that is listening for web hooks
app.post('/webhook', spark.webhookListen());// start express server
app.listen(port, function() {
// get exisiting webhooks
spark.webhooksGet()
// remove all existing webhooks
.then(webhooks => when.map(webhooks, webhook => spark.webhookRemove(webhook.id)))
// create spark webhook directed back to the externally accessible
// express route defined above.
.then(() => spark.webhookAdd({
name: 'my webhook',
targetUrl: 'https://example.com/webhook',
resource: 'all',
event: 'all',
});
console.log(`Listening on port ${port}`);
});
```## Using node-sparky in the Browser
You can use node-sparky on the client side browser as well. Simply include
`` in your page and you can use
node-sparky just as you can with with node-js.```html
test
Test
$(document).ready(function() {
var spark = new Sparky({
token: '<my token>'
});var message = {
roomId: '<room id>',
text: 'Hello world!'
};spark.messageSend(message)
.then(function(res) {
$('#messageId').html(res.id);
})
.catch(function(err) {
console.log(err);
});
});