sparklite
Version:
A lite node API to access Cisco Spark resources
44 lines (32 loc) • 1.48 kB
Markdown
this NPM is to provide a light weight API layer for rapid prototyping of Cisco Spark bots.
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.
```javascript
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!');
});
})
```
The tests are implemented with mocha, to execute them run the following command:
> npm test
The purpose of