Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const webHookUrl = "http://localhost:"+PORT+"/ciscospark/receive";
var sparkwebsocket = new SparkWebSocket(accessToken);
sparkwebsocket.connect(function(err){
if (!err) {
if(webHookUrl)
sparkwebsocket.setWebHookURL(webHookUrl);
}else {
console.log("Error starting up websocket: "+err);
}
});
////// Bot Kit //////
const Botkit = require('botkit');
var controller = Botkit.sparkbot({
stats_optout: true,
debug: true,
log: true,
public_address: "https://localhost",
ciscospark_access_token: process.env.BOTTOKEN
});
var bot = controller.spawn({
});
controller.setupWebserver(PORT, function(err, webserver) {
//setup incoming webhook handler
webserver.post('/ciscospark/receive', function(req, res) {
controller.handleWebhookPayload(req, res, bot);
});
var SparkWebSocket = require('ciscospark-websocket-events');
sparkwebsocket = new SparkWebSocket(accessToken);
sparkwebsocket.connect(function (err, res) {
if (!err) {
sparkwebsocket.setWebHookURL("http://localhost:" + PORT + "/ciscospark/receive");
}
else {
console.log("Error starting up websocket: " + err);
}
})
//////// Bot Kit //////
var Botkit = require('botkit');
var controller = Botkit.sparkbot({
debug: true,
log: true,
public_address: "https://localhost",
ciscospark_access_token: accessToken
});
var bot = controller.spawn({
});
controller.setupWebserver(PORT, function (err, webserver) {
//setup incoming webhook handler
webserver.post('/ciscospark/receive', function (req, res) {
res.sendStatus(200)
controller.handleWebhookPayload(req, res, bot);
});