Toggle navigation
Toggle navigation
This project
Loading...
Sign in
방승일
/
find_mbti_bot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Minkyung Ko
2022-06-03 13:34:09 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
5d539148313ee8cf199de06a226926751ded58ef
5d539148
2 parents
c9ccb054
95fde420
Merge branch 'feature/question8to14'
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
333 additions
and
130 deletions
app/app.js
app/app.js
View file @
5d53914
...
...
@@ -5,6 +5,7 @@ const bodyParser = require('body-parser');
const
apiRouter
=
express
.
Router
();
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
...
...
@@ -13,47 +14,90 @@ app.use(bodyParser.urlencoded({
app
.
use
(
'/api'
,
apiRouter
);
let
userDB
=
new
Array
();
let
mbtiper
=
new
Array
();
apiRouter
.
post
(
'/
sayHello'
,
function
(
req
,
res
)
{
apiRouter
.
post
(
'/
test'
,
(
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 테스트 시작하기"
}
]
}
}
]
}
};
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'MBTI 테스트 question8-14\n시작하려면 시작하기 버튼을 눌러주세요!'
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"시작하기"
,
message
:
"시작하기"
,
blockId
:
"62977ff05ceed96c385449b9"
},
{
action
:
"block"
,
label
:
"나중에 하기"
,
message
:
"나중에 하기"
,
blockId
:
"6297861be7a0253c7662ccb8"
}
]
}
}
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
]);
apiRouter
.
post
(
'/question8'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
userDB
[
userId
]
=
[
''
,
''
,
''
,
''
,
''
];
console
.
log
(
userDB
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'[question8]\n여행 계획을 어떻게 세우시나요?'
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"테마만 정한다(ex.맛집 방문하는 날, 사진 찍는 날)"
,
message
:
"테마만 정한다(ex.맛집 방문하는 날, 사진 찍는 날)"
,
blockId
:
"629780e9e7a0253c7662cca6"
},
{
action
:
"block"
,
label
:
"시간과 장소를 자세하게 정한다"
,
message
:
"시간과 장소를 자세하게 정한다"
,
blockId
:
"629780e9e7a0253c7662cca6"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question9'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mbti
=
''
;
if
(
mesg
==
"테마만 정한다(ex.맛집 방문하는 날, 사진 찍는 날)"
){
mbti
=
'P'
;
}
else
if
(
mesg
==
"시간과 장소를 자세하게 정한다"
)
{
mbti
=
'J'
;
}
userDB
[
userId
][
3
]
+=
mbti
;
console
.
log
(
userDB
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'
사람들과 어울리는 것을 좋아하시나요?
'
text
:
'
[question9]\n재미있는 책이나 비디오 게임이 사교 모임보다 더 낫습니다.
'
}
}
],
...
...
@@ -62,13 +106,13 @@ apiRouter.post('/question1', (req, res) => {
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"62
8e8cb07bd2fd433357f878
"
blockId
:
"62
9780f4ab89e678ee86b2de
"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"62
8e8cb07bd2fd433357f878
"
blockId
:
"62
9780f4ab89e678ee86b2de
"
}
]
}
...
...
@@ -76,25 +120,25 @@ apiRouter.post('/question1', (req, res) => {
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question
2
'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
console
.
log
(
'[q2:user message] '
,
mesg
)
;
var
mbti
=
''
;
if
(
mesg
==
"네"
)
{
mbti
=
'E'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'I
'
;
}
userDB
[
userId
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]
);
const
responseBody
=
{
apiRouter
.
post
(
'/question
10
'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mbti
=
''
;
if
(
mesg
==
"네"
){
mbti
=
'I'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'E
'
;
}
userDB
[
userId
][
0
]
+=
mbti
;
console
.
log
(
userDB
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'
평소 깻잎논쟁에 1시간 이상을 생각해봤
다.'
text
:
'
[question10]\n본인이 창의적이기보다 현실적인 사람이라고 생각합니
다.'
}
}
],
...
...
@@ -103,13 +147,13 @@ apiRouter.post('/question2', (req, res) => {
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"62
8d239d93b31d5b60ab6c29
"
blockId
:
"62
9781015ceed96c385449c8
"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"62
8d239d93b31d5b60ab6c29
"
blockId
:
"62
9781015ceed96c385449c8
"
}
]
}
...
...
@@ -117,121 +161,280 @@ apiRouter.post('/question2', (req, res) => {
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question
3'
,
function
(
req
,
res
)
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
console
.
log
(
'[q3:user message] '
,
mesg
)
;
var
mbti
=
''
;
if
(
mesg
==
'네'
)
{
mbti
=
'N'
;
}
else
if
(
mesg
==
'아니오'
)
{
mbti
=
'S
'
;
}
userDB
[
userId
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
"simpleText"
:
{
"text"
:
"다음과 같은 상황에서 어떻게 대답하겠습니까?\n 친구: 나 기분 안 좋아서 옷 샀어"
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"왜 기분 안 좋아?
"
,
message
:
"왜 기분 안 좋아?
"
,
blockId
:
"6290630451c40d32c6d8e71f
"
},
{
action
:
"block"
,
label
:
"무슨 옷 샀어?
"
,
message
:
"무슨 옷 샀어?
"
,
blockId
:
"6290630451c40d32c6d8e71f
"
}
]
}
};
res
.
status
(
200
).
send
(
responseBody
);
apiRouter
.
post
(
'/question
11'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mbti
=
''
;
if
(
mesg
==
"네"
){
mbti
=
'S'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'N
'
;
}
userDB
[
userId
][
1
]
+=
mbti
;
console
.
log
(
userDB
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'[question11]\n팀플을 하는 경우, 충실하지만 실적을 못 내는 팀원을 제명하기 어려워합니다.'
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"네
"
,
message
:
"네
"
,
blockId
:
"6297810fe7a0253c7662cca8
"
},
{
action
:
"block"
,
label
:
"아니오
"
,
message
:
"아니오
"
,
blockId
:
"6297810fe7a0253c7662cca8
"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question4'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
apiRouter
.
post
(
'/question12'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
console
.
log
(
'[q4:user message] '
,
mesg
);
var
mbti
=
''
;
if
(
mesg
==
"왜 기분 안 좋아?"
)
{
mbti
=
'F'
;
}
else
if
(
mesg
==
"무슨 옷 샀어?"
)
{
mbti
=
'T'
;
}
userDB
[
userId
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]);
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mbti
=
''
;
if
(
mesg
==
"네"
){
mbti
=
'F'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'T'
;
}
userDB
[
userId
][
2
]
+=
mbti
;
console
.
log
(
userDB
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
"그날 할 일에 대해 계획을 미리 세우시나요?"
text
:
'[question12]\n집과 업무 환경이 잘 정돈되어 있습니다.'
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"6293885b7bd2fd4333583df0
"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6293885b7bd2fd4333583df0
"
}
]
{
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"6297811bf591aa190554a22e
"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6297811bf591aa190554a22e
"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/result'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
apiRouter
.
post
(
'/question13'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
console
.
log
(
'[result:user message] '
,
mesg
);
var
mbti
=
''
;
if
(
mesg
==
"네"
)
{
mbti
=
'J'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'P'
;
}
userDB
[
userId
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]);
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mbti
=
''
;
if
(
mesg
==
"네"
){
mbti
=
'J'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'P'
;
}
userDB
[
userId
][
3
]
+=
mbti
;
console
.
log
(
userDB
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
"당신의 MBTI는 : "
+
userDB
[
userId
]
text
:
'[question13]\n친구 관계가 좁고 깊은 편입니다.'
}
}
],
quickReplies
:
[{
action
:
"block"
,
label
:
"MBTI 테스트 다시하기"
,
message
:
"MBTI 테스트 다시하기"
,
blockId
:
"628b8005055a574d7df54466"
}]
quickReplies
:
[
{
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"62978127ab89e678ee86b2e2"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"62978127ab89e678ee86b2e2"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question14'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mbti
=
''
;
if
(
mesg
==
"네"
){
mbti
=
'I'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'E'
;
}
userDB
[
userId
][
0
]
+=
mbti
;
console
.
log
(
userDB
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'[question14]\n공부하기 싫을 때 공부는 왜 해야 하는 것인지 고민에 빠질 때가 있습니다.'
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"62979c9ce7a0253c7662ccd4"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"62979c9ce7a0253c7662ccd4"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/result'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
mbtiper
=
[
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
];
var
mbti
=
''
;
if
(
mesg
==
"네"
){
mbti
=
'N'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'S'
;
}
userDB
[
userId
][
1
]
+=
mbti
;
var
e
=
0
;
var
n
=
0
;
var
f
=
0
;
var
j
=
0
;
for
(
i
=
0
;
i
<
2
;
i
++
){
if
(
userDB
[
userId
][
0
][
i
]
==
"E"
){
e
++
;
}
}
for
(
i
=
0
;
i
<
2
;
i
++
){
if
(
userDB
[
userId
][
1
][
i
]
==
"N"
){
n
++
;
}
}
for
(
i
=
0
;
i
<
1
;
i
++
){
if
(
userDB
[
userId
][
2
][
i
]
==
"F"
){
f
++
;
}
}
for
(
i
=
0
;
i
<
2
;
i
++
){
if
(
userDB
[
userId
][
3
][
i
]
==
"J"
){
j
++
;
}
}
var
i
=
2
-
e
;
var
s
=
2
-
n
;
var
t
=
1
-
f
;
var
p
=
2
-
j
;
mbtiper
[
0
]
+=
20
*
e
;
mbtiper
[
1
]
+=
20
*
i
;
mbtiper
[
2
]
+=
20
*
n
;
mbtiper
[
3
]
+=
20
*
s
;
mbtiper
[
4
]
+=
20
*
t
;
mbtiper
[
5
]
+=
20
*
f
;
mbtiper
[
6
]
+=
20
*
j
;
mbtiper
[
7
]
+=
20
*
p
;
if
(
mbtiper
[
0
]
>
mbtiper
[
1
]){
userDB
[
userId
][
4
]
+=
'E'
;
}
else
{
userDB
[
userId
][
4
]
+=
'I'
;
}
if
(
mbtiper
[
2
]
>
mbtiper
[
3
]){
userDB
[
userId
][
4
]
+=
'N'
;
}
else
{
userDB
[
userId
][
4
]
+=
'S'
;
}
if
(
mbtiper
[
4
]
>
mbtiper
[
5
]){
userDB
[
userId
][
4
]
+=
'T'
;
}
else
{
userDB
[
userId
][
4
]
+=
'F'
;
}
if
(
mbtiper
[
6
]
>
mbtiper
[
7
]){
userDB
[
userId
][
4
]
+=
'J'
;
}
else
{
userDB
[
userId
][
4
]
+=
'P'
;
}
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
"당신의 MBTI는 : "
+
userDB
[
userId
][
4
]
}
}
],
quickReplies
:
[{
action
:
"block"
,
label
:
"MBTI 테스트 다시하기"
,
message
:
"MBTI 테스트 다시하기"
,
blockId
:
"62977ff05ceed96c385449b9"
},
{
action
:
"block"
,
label
:
"결과 상세보기"
,
message
:
"결과 상세보기"
,
blockId
:
"62987b78e7a0253c7662dcd9"
}]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/percent'
,
(
req
,
res
)
=>
{
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'E: '
+
mbtiper
[
0
]
+
'%\nI: '
+
mbtiper
[
1
]
+
'%\nN: '
+
mbtiper
[
2
]
+
'%\nS: '
+
mbtiper
[
3
]
+
'%\nT: '
+
mbtiper
[
4
]
+
'%\nF: '
+
mbtiper
[
5
]
+
'%\nJ: '
+
mbtiper
[
6
]
+
'%\nP: '
+
mbtiper
[
7
]
+
'%'
}
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
app
.
listen
((
process
.
env
.
PORT
||
3000
),
function
()
{
console
.
log
(
'Example skill server listening on port 3000!'
);
});
\ No newline at end of file
...
...
Please
register
or
login
to post a comment