김성욱

Add question4, 5

...@@ -158,6 +158,88 @@ apiRouter.post('/question3', function(req, res) { ...@@ -158,6 +158,88 @@ apiRouter.post('/question3', function(req, res) {
158 res.status(200).send(responseBody); 158 res.status(200).send(responseBody);
159 }); 159 });
160 160
161 +apiRouter.post('/question4', (req, res) => {
162 + var userId = req.body.userRequest.user.id;
163 + var mesg = req.body.userRequest.utterance;
164 + console.log('[q4:user message] ', mesg);
165 + var mbti = '';
166 + if (mesg == "네") {
167 + mbti = 'T';
168 + } else if (mesg == "아니오") {
169 + mbti = 'F';
170 + }
171 + userDB[userId][2] += mbti;
172 + console.log(userDB[userId]);
173 + const responseBody = {
174 + version: "2.0",
175 + template: {
176 + outputs: [
177 + {
178 + simpleText: {
179 + text: "주의깊게 미리 계획하기 보다는 즉흥적으로 움직입니다."
180 + }
181 + }
182 + ],
183 + quickReplies: [
184 + {
185 + action: "block",
186 + label: "네",
187 + message: "네",
188 + blockId: "6297b12be7a0253c7662ccec"
189 + },
190 + {
191 + action: "block",
192 + label: "아니오",
193 + message: "아니오",
194 + blockId: "6297b12be7a0253c7662ccec"
195 + }
196 + ]
197 + }
198 + }
199 + res.status(200).send(responseBody);
200 +});
201 +
202 +apiRouter.post('/question5', (req, res) => {
203 + var userId = req.body.userRequest.user.id;
204 + var mesg = req.body.userRequest;
205 + console.log('[q1:user message] ', mesg);
206 + var mbti = '';
207 + if (mesg == "네") {
208 + mbti = 'P';
209 + } else if (mesg == "아니오") {
210 + mbti = 'J';
211 + }
212 + userDB[userId][3] += mbti;
213 + console.log(userDB[userId]);
214 + const responseBody = {
215 + version: "2.0",
216 + template: {
217 + outputs: [
218 + {
219 + simpleText: {
220 + text: '주목받는 것을 좋아합니다.'
221 + }
222 + }
223 + ],
224 + quickReplies: [
225 + {
226 + action: "block",
227 + label: "네",
228 + message: "네",
229 + blockId: "6297b130e7a0253c7662ccee"
230 + },
231 + {
232 + action: "block",
233 + label: "아니오",
234 + message: "아니오",
235 + blockId: "6297b130e7a0253c7662ccee"
236 + }
237 + ]
238 + }
239 + }
240 + res.status(200).send(responseBody);
241 +});
242 +
161 app.listen((process.env.PORT || 3000), function() { 243 app.listen((process.env.PORT || 3000), function() {
162 console.log('Example skill server listening on port 3000!'); 244 console.log('Example skill server listening on port 3000!');
163 }); 245 });
...\ No newline at end of file ...\ No newline at end of file
......