Miss any of our Open RFC calls?Watch the recordings here! »

sparklite

2.0.0 • Public • Published

Synopsis

The purpose of this NPM is to provide a light weight API layer for rapid prototyping of Cisco Spark bots.

Motivation

This projects abstracts and reduces the communication with Cisco Spark services into consuming simple JS API that we, developers, understand better. Ultimately what a developer wants to focus is in the business logic, which is the fun part.

Code Example

 
var port = process.env.PORT || 80;
var sparklite = require("sparklite");
var botdomain = 'MY_BOT_DOMAIN.net'; // i.e “dolores.cisco.net”
var sparkBot = new sparklite.SparkBot(My_Spark_Token, port, botdomain);
 
sparkBot.printHelloWorld();
 //before version 2.0.0
sparkBot.on('message', function (event)
{
    console.log('Incoming message: '+ JSON.stringify(event.message) + ' from: '+event.person.displayName );
    var sentMessage = 'Hola ' + event.person.displayName;
 
    sparkBot.sendMessage(event.roomId, sentMessage , function(){
      console.log('Message sent from Bot!');
    });
 })
 
 //after version 2.0.0
 sparkBot.sparkBotEmitter.on('message', function(event) {
   console.log('Incoming message: '+ JSON.stringify(event.message) + ' from: '+event.person.displayName );
   var sentMessage = 'Hola ' + event.person.displayName;
 
   sparkBot.sendMessage(event.roomId, sentMessage , function(){
     console.log('Message sent from Bot!');
   });
})

Tests

The tests are implemented with mocha, to execute them run the following command:

npm test

Install

npm i sparklite

DownloadsWeekly Downloads

12

Version

2.0.0

License

ISC

Unpacked Size

45.9 kB

Total Files

10

Last publish

Collaborators

  • avatar