-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
45 lines (37 loc) · 1010 Bytes
/
bot.js
File metadata and controls
45 lines (37 loc) · 1010 Bytes
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
'use strict';
/**
* API Key & Token
*/
const SlackToken = '<Your Bot Slack Token>';
const GoogleAPIKey = '<Your Google API Key>';
const GoogleCXCode = '<Your Google CX ID>';
/**
* Define Required vars
*/
const botkit = require( 'botkit' ),
BOT = require( './lib/bot_helper' )( {
GoogleAPIKey: GoogleAPIKey,
GoogleCXCode: GoogleCXCode
});
/**
* Build up Slack
*/
const controller = botkit.slackbot();
const bot = controller.spawn( {
token: SlackToken
});
/**
* Fireup Slack's Real Time Messaging
*/
bot.startRTM( function( err, bot, payload ) {
if( err ){
throw new Error( 'Could not connect to Slack' );
}
});
/**
* Bot Listening...
*/
controller.hears( [ 'find me (.*)' ], 'direct_message,direct_mention,mention', function( bot, message ) {
bot.reply( message, 'Yes sir! Hold on a sec...' );
BOT.process( bot, message, message.match[ 1 ] );
});