This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbot.js
52 lines (40 loc) · 1.72 KB
/
bot.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
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
______ ______ ______ __ __ __ ______
/\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\
\ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
This is a sample Google Hangouts Chat bot built with Botkit.
# RUN THE BOT :
Follow the instructions here to set up your Facebook app and page:
-> https://developers.google.com/hangouts/chat/how-tos/bots-publish
Run your bot from the command line:
DEBUG=botkit:* \
PORT=YOUR_APP_PORT \
GOOGLE_APPLICATION_CREDENTIALS=YOUR_GOOGLE_CREDENTIALS_FILE \
GOOGLE_VERIFICATION_TOKEN=YOUR_GOOGLE_VERIFICATION_TOKEN \
node bot.js
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
const env = require('node-env-file');
env(__dirname + '/.env');
if (!process.env.GOOGLE_APPLICATION_CREDENTIALS) {
console.log('Error: Specify a GOOGLE_APPLICATION_CREDENTIALS in environment.');
process.exit(1);
}
const Botkit = require('botkit');
const endpoint = "receive";
const token = process.env.GOOGLE_VERIFICATION_TOKEN;
const port = process.env.PORT || 3000;
const debug = true;
const controller = Botkit.googlehangoutsbot({
endpoint,
token,
port,
debug,
});
const bot = controller.spawn({});
const webserver = require(__dirname + '/components/express_webserver.js')(controller, bot);
const normalizedPath = require("path").join(__dirname, "skills");
require("fs").readdirSync(normalizedPath).forEach(function(file) {
require("./skills/" + file)(controller);
});