forked from SunilSyal/Webhook-and-API.AI-Echo-Sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·82 lines (68 loc) · 2.15 KB
/
Copy pathindex.js
File metadata and controls
executable file
·82 lines (68 loc) · 2.15 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
const restService = express();
restService.use(bodyParser.urlencoded({
extended: true
}));
restService.use(bodyParser.json());
restService.post('/echo', function(req, res) {
var speech = req.body.result && req.body.result.parameters && req.body.result.parameters.echoText ? req.body.result.parameters.echoText : "Seems like some problem. Speak again."
return res.json({
speech: speech,
displayText: speech,
source: 'webhook-echo-sample'
});
});
restService.post('/slack-test', function(req, res) {
var slack_message = {
"text": "Details of JIRA board for Browse and Commerce",
"attachments": [{
"title": "JIRA Board",
"title_link": "http://www.google.com",
"color": "#36a64f",
"fields": [{
"title": "Epic Count",
"value": "50",
"short": "false"
}, {
"title": "Story Count",
"value": "40",
"short": "false"
}],
"thumb_url": "https://stiltsoft.com/blog/wp-content/uploads/2016/01/5.jira_.png"
}, {
"title": "Story status count",
"title_link": "http://www.google.com",
"color": "#f49e42",
"fields": [{
"title": "Not started",
"value": "50",
"short": "false"
}, {
"title": "Development",
"value": "40",
"short": "false"
}, {
"title": "Development",
"value": "40",
"short": "false"
}, {
"title": "Development",
"value": "40",
"short": "false"
}]
}]
}
return res.json({
speech: "speech",
displayText: "speech",
source: 'webhook-echo-sample',
data: {
"slack": slack_message
}
});
});
restService.listen((process.env.PORT || 8000), function() {
console.log("Server up and listening");
});