app.js
2.2 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
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const apiRouter = express.Router();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use('/api', apiRouter);
let userDB = new Array();
apiRouter.post('/sayHello', function(req, res) {
const responseBody = {
version: "2.0",
template: {
outputs: [
{
"basicCard": {
"title": "MBTI 검사 챗봇",
"description": "MBTI 검사 챗봇입니다! \n당신의 MBTI를 찾아보세요!",
"thumbnail": {
"imageUrl": "https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fsnm5S%2Fbtq6cSXUkrD%2FOgk9QsUoPzQGvllliI0CSk%2Fimg.jpg"
},
"buttons": [
{
"action": "message",
"label": "MBTI 테스트 시작하기",
"messageText": "MBTI 테스트 시작하기"
}
]
}
}
]
}
};
res.status(200).send(responseBody);
});
apiRouter.post('/question1', (req, res) => {
var userId = req.body.userRequest.user.id;
var mesg = req.body.userRequest;
console.log('[q1:user message] ', mesg);
userDB[userId] = ['','','','',''];
console.log(userDB[userId]);
const responseBody = {
version: "2.0",
template: {
outputs: [
{
simpleText: {
text: '금방 새로운 직장 사람들과 어울리기 시작합니다.'
}
}
],
quickReplies: [
{
action: "block",
label: "네",
message: "네",
blockId: "6297b11ae7a0253c7662ccea"
},
{
action: "block",
label: "아니오",
message: "아니오",
blockId: "6297b11ae7a0253c7662ccea"
}
]
}
}
res.status(200).send(responseBody);
});
app.listen((process.env.PORT || 3000), function() {
console.log('Example skill server listening on port 3000!');
});