-
Notifications
You must be signed in to change notification settings - Fork 27
/
index.js
49 lines (38 loc) · 1.1 KB
/
index.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
'use strict';
// Include the serverless-slack bot framework
const slack = require('serverless-slack');
// The function that AWS Lambda will call
exports.handler = slack.handler.bind(slack);
// Slash Command handler
slack.on('/greet', (msg, bot) => {
let message = {
text: "How would you like to greet the channel?",
attachments: [{
fallback: 'actions',
callback_id: "greetings_click",
actions: [
{ type: "button", name: "Wave", text: ":wave:", value: ":wave:" },
{ type: "button", name: "Hello", text: "Hello", value: "Hello" },
{ type: "button", name: "Howdy", text: "Howdy", value: "Howdy" },
{ type: "button", name: "Hiya", text: "Hiya", value: "Hiya" }
]
}]
};
// ephemeral reply
bot.replyPrivate(message);
});
// Interactive Message handler
slack.on('greetings_click', (msg, bot) => {
let message = {
// selected button value
text: msg.actions[0].value
};
// public reply
bot.reply(message);
});
// Reaction Added event handler
slack.on('reaction_added', (msg, bot) => {
bot.reply({
text: ':wave:'
});
});