-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-webhook.js
43 lines (40 loc) · 1.21 KB
/
post-webhook.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
var fetch = require('node-fetch');
var env = require('node-env-file');
env(__dirname + '/.env');
let slackMessage = {
"attachments": [{
"title": "Rental Approval Request",
"text": "Rental <https://www.outdoorsy.com|#1234> has been flagged by Jane Doe\nReason: Fraudulent. Would you like to approve or delete?",
"fallback": "Rental #1234 has been flagged by Jane Doe; Reason: Fraudulent",
"callback_id": "rental_1234_flagged",
"color": "warning",
"attachment_type": "default",
"actions": [{
"name": "choice",
"text": "Approve",
"type": "button",
"value": "approve",
"style": "primary"
}, {
"name": "choice",
"text": "Delete",
"type": "button",
"value": "delete",
"style": "danger",
"confirm": {
"text": "This will remove the listing from Outdoorsy",
"title": "Are you sure?",
"ok_text": "Yes",
"dismiss_text": "No"
}
}]
}]
};
return fetch(process.env.INCOMING_WEBHOOK, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': process.env.ASANA_TOKEN
},
body: JSON.stringify(slackMessage)
}).then(res => res.text()).then(data => console.log(data));