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
공정훈
2022-05-30 09:28:10 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9daddc038a96e28226ab7919352fe4cff6a42c84
9daddc03
1 parent
29bb83c0
Update block connection
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
133 additions
and
58 deletions
app/app.js
app/app.js
View file @
9daddc0
...
...
@@ -36,7 +36,7 @@ apiRouter.post('/sayHello', function(req, res) {
apiRouter
.
post
(
'/test'
,
(
req
,
res
)
=>
{
var
utt
=
req
.
body
.
userRequest
.
utterance
;
var
data
=
{
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
...
...
@@ -50,22 +50,17 @@ apiRouter.post('/test', (req, res) => {
action
:
"block"
,
label
:
"테스트 시작"
,
message
:
"테스트 시작"
,
data
:
{
"blockId"
:
"628b8005055a574d7df54466"
,
"extra"
:
{
""
:
""
}
}
blockId
:
"628b8005055a574d7df54466"
}]
}
}
res
.
json
(
data
);
res
.
status
(
200
).
send
(
responseBody
);
});
ap
p
.
post
(
'/question1'
,
(
req
,
res
)
=>
{
ap
iRouter
.
post
(
'/question1'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
;
console
.
log
(
'[user message] '
,
mesg
);
var
data
=
{
console
.
log
(
'[
q1:
user message] '
,
mesg
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
...
...
@@ -77,88 +72,168 @@ app.post('/question1', (req, res) => {
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
data
:
{
"blockId"
:
"628e8cb07bd2fd433357f878"
,
"extra"
:
{
""
:
""
}
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"628e8cb07bd2fd433357f878"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"628e8cb07bd2fd433357f878"
}
},
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question2'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
console
.
log
(
'[q2:user message] '
,
mesg
);
var
mbti
=
''
;
if
(
mesg
==
"네"
)
{
mbti
=
'E'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'I'
;
}
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
data
:
{
"blockId"
:
"628e8cb07bd2fd433357f878"
,
"extra"
:
{
""
:
""
}
simpleText
:
{
text
:
'mbti:'
+
mbti
+
'***\n평소 깻잎논쟁에 1시간 이상을 생각해봤다.\n맞다면 N 아니면 S을 입력해주세요.'
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"628d239d93b31d5b60ab6c29"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"628d239d93b31d5b60ab6c29"
}
]
}
}
res
.
json
(
data
);
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question3'
,
function
(
req
,
res
)
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
console
.
log
(
'[q3:user message] '
,
mesg
);
var
mbti
=
''
;
if
(
mesg
==
'네'
)
{
mbti
=
'N'
;
}
else
if
(
mesg
==
'아니오'
)
{
mbti
=
'S'
;
}
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
"simpleText"
:
{
"text"
:
"다음과 같은 상황에서 어떻게 대답하겠습니까? 해당 숫자를 입력해 주세요. \n 친구: 나 기분 안 좋아서 옷 샀어 \n 1. 왜 기분 안 좋아? \n 2. 무슨 옷 샀어?"
"text"
:
"
mbti:*"
+
mbti
+
"**\n
다음과 같은 상황에서 어떻게 대답하겠습니까? 해당 숫자를 입력해 주세요. \n 친구: 나 기분 안 좋아서 옷 샀어 \n 1. 왜 기분 안 좋아? \n 2. 무슨 옷 샀어?"
}
}
]
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"왜 기분 안 좋아?"
,
message
:
"왜 기분 안 좋아?"
,
blockId
:
"6290630451c40d32c6d8e71f"
},
{
action
:
"block"
,
label
:
"무슨 옷 샀어?"
,
message
:
"무슨 옷 샀어?"
,
blockId
:
"6290630451c40d32c6d8e71f"
}
]
}
};
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/Q2'
,
function
(
req
,
res
)
{
apiRouter
.
post
(
'/question4'
,
(
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'
;
}
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'평소 깻잎논쟁에 1시간 이상을 생각해봤다.\n맞다면 N 아니면 S을 입력해주세요.'
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
"mbti:**"
+
mbti
+
"*\n그날 할 일에 대해 계획을 미리 세우시나요?"
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"6293885b7bd2fd4333583df0"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6293885b7bd2fd4333583df0"
}
}
]
}
};
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/A2'
,
function
(
req
,
res
)
{
const
userRequest
=
req
.
body
.
userRequest
;
const
utter
=
userRequest
.
utterance
;
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'당신의 MBTI는 *'
+
utter
+
'** 입니다.'
}
apiRouter
.
post
(
'/result'
,
(
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'
;
}
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
"mbti: ***"
+
mbti
}
}
],
quickReplies
:
[{
action
:
"block"
,
label
:
"mbti 결과 보기"
,
message
:
"mbti 결과 보기"
,
blockId
:
"629045977befc3101c3be778"
}]
}
]
}}
}
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