-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
64 lines (51 loc) · 2.34 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
______ ______ ______ __ __ __ ______
/\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\
\ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
This is a Cisco Spark bot built with Botkit.
# RUN THE BOT:
Follow the instructions here to set up your Cisco Spark bot:
-> https://developer.ciscospark.com/bots.html
Run your bot from the command line:
access_token=<MY BOT ACCESS TOKEN> public_address=<MY PUBLIC HTTPS URL> node bot.js
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// var env = require('node-env-file');
// env(__dirname + '/.env');
console.log(process.env.access_token);
if (!process.env.access_token) {
console.log('Error: Specify a Cisco Spark access_token in environment.');
//usage_tip();
process.exit(1);
}
if (!process.env.public_address) {
console.log('Error: Specify an SSL-enabled URL as this bot\'s public_address in environment.');
//usage_tip();
process.exit(1);
}
var Botkit = require('botkit');
var debug = require('debug')('botkit:main');
// Create the Botkit controller, which controls all instances of the bot.
var controller = Botkit.sparkbot({
debug: true,
log: true,
//limit_to_domain: 'cdw.com',
// limit_to_org: 'my_cisco_org_id',
public_address: process.env.public_address,
ciscospark_access_token: process.env.access_token,
studio_token: process.env.studio_token, // get one from studio.botkit.ai to enable content management, stats, message console and more
secret: process.env.secret, // this is an RECOMMENDED but optional setting that enables validation of incoming webhooks
webhook_name: 'mrmeeseeks-webhook'
});
var bot = controller.spawn({});
controller.setupWebserver(process.env.PORT || 3001, function(err, webserver) {
controller.createWebhookEndpoints(webserver, bot, function() {
console.log("Cisco Spark: Webhooks set up!");
});
});
// Load events and skills
var normalizedPath = require("path").join(__dirname, "skills");
require("fs").readdirSync(normalizedPath).forEach(function(file) {
require("./skills/" + file)(controller);
});