Watson์œผ๋กœ ์‰ฝ๊ฒŒ ๋งŒ๋“œ๋Š” ์นด์นด์˜คํ†ก ChatBot

์ด ํฌ์ŠคํŒ…์€ 2. ๋‚ด๊ฐ€ ๋งŒ๋“  ์ฑ„ํŒ… ์„œ๋น„์Šค๋ฅผ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์œผ๋กœ ๋…ธ์ถœํ•˜๊ธฐ์— ์ด์–ด์ง€๋Š” ํฌ์ŠคํŒ…์ž…๋‹ˆ๋‹ค. ์ด ๋‹จ๊ณ„์—์„œ๋Š” ํšŒ์˜์‹ค ์˜ˆ์•ฝ์„ ์œ„ํ•œ Backend ์„œ๋น„์Šค๋ฅผ ์˜ฌ๋ฆฌ๊ณ  ๋Œ€ํ™”๋ฅผ ํ†ตํ•ด ์˜ˆ์•ฝํ•˜๊ธฐ๊นŒ์ง€์˜ ๋‹จ๊ณ„๋ฅผ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

< ์ด ํฌ์ŠคํŒ…๊ณผ ์—ฐ๊ฒฐ๋œ ๊ธ€ ๋ชฉ๋ก >

3. ๋Œ€ํ™” ๋‚ด์šฉ์œผ๋กœ ํšŒ์˜์‹ค ์˜ˆ์•ฝํ•˜๊ธฐ

2.1 Simple-RBS ์„œ๋น„์Šค ๋””ํ”Œ๋กœ์ด ํ•˜๊ธฐ

์ด ํฌ์ŠคํŒ…์—์„œ๋Š” ์ด๋ฏธ ๋งŒ๋“ค์–ด์ ธ ์žˆ๋Š” ํšŒ์˜์‹ค ์˜ˆ์•ฝ ์‹œ์Šคํ…œ์„ ๊ฐ์ž์˜ ๋ธ”๋ฃจ๋ฏน์Šค์— ๋””ํ”Œ๋กœ์ด ํ•˜์—ฌ ์‚ฌ์šฉํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.

1)Simple-RBS์˜ github์—์„œ Deploy to Bluemix ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

deployRBS01

2)๋กœ๊ทธ์ธ ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๋กœ๊ทธ์ธํ•ฉ๋‹ˆ๋‹ค.

deployRBS02

3) ํšŒ์˜์‹ค ์˜ˆ์•ฝ ์‹œ์Šคํ…œ์ด ์‚ฌ์šฉํ•  ํ˜ธ์ŠคํŠธ๋„ค์ž„์„ ์ž…๋ ฅํ•˜๊ณ  Bluemix์˜ Region, Organization, Space๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ํ˜ธ์ŠคํŠธ๋„ค์ž„์€ ๋ธ”๋ฃจ๋ฏน์Šค ๋‚ด์—์„œ ์œ ์ผํ•œ ๊ฐ’์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

deployRBS03

4) Deploy๊ฐ€ ์™„๋ฃŒ๋œ ํ›„ ๋ธ”๋ฃจ๋ฏน์Šค์˜ ๋Œ€์‰ฌ๋ณด๋“œ๋ฅผ ๋ณด๋ฉด ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์ƒ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ฃผ์†Œ๋ฅผ ๋ˆ„๋ฅด๋ฉด ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์œผ๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.

deployRBS04

5) ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ํšŒ์˜์‹ค ์˜ˆ์•ฝ ์‹œ์Šคํ…œ์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” API๋ชฉ๋ก์„ ํ™•์ธํ•˜๊ณ  API๋ฅผ ํ…Œ์ŠคํŠธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

deployRBS05

2.2 Simple-RBS ์‹œ์Šคํ…œ์— ์‚ฌ์ดํŠธ, ๋ฏธํŒ…๋ฃธ ์ƒ์„ฑํ•˜๊ธฐ

์œ„ ๋‹จ๊ณ„์—์„œ ์ƒ์„ฑํ•œ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์— ์‚ฌ์ดํŠธ์™€ ๋ฏธํŒ…๋ฃธ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

1) ๋จผ์ € Site API์— ์žˆ๋Š” POST /site ๋…ธ๋“œ๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

Parameters ์„น์…˜์„ ๋ณด๋ฉด ์ขŒ์ธก์— Value๋ฅผ ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ๊ณ  ์šฐ์ธก์— Example Value๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

2) Example Value ๋ฐ•์Šค๋ฅผ ํด๋ฆญํ•˜๋ฉด Value ์ž…๋ ฅ ์ฐฝ์— ์ž๋™์œผ๋กœ Example Value๊ฐ€ ์ž…๋ ฅ๋ฉ๋‹ˆ๋‹ค.

3) JSON Object์˜ siteid ๊ฐ’์„ camomile๋กœ ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.

4) Try it out! ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด API๊ฐ€ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค.

deployRBS06

Try it out! ๋ฒ„ํŠผ์„ ํด๋ฆญํ•œ ํ›„์— ์•„๋ž˜์ฒ˜๋Ÿผ response ์ฝ”๋“œ๊ฐ€ 200์œผ๋กœ ๋‚˜ํƒ€๋‚˜๋ฉด ์ •์ƒ์ ์œผ๋กœ ์ฒ˜๋ฆฌ๋œ ๊ฒƒ ์ž…๋‹ˆ๋‹ค.

deployRBS07

๋งˆ์ฐฎ๊ฐ€์ง€๋กœ ์‚ฌ์ดํŠธ ๋‚ด์— ์œ„์น˜ํ•  ํšŒ์˜์‹ค์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

5) Room API์— ์žˆ๋Š” POST /room ๋…ธ๋“œ๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

6) ๋งˆ์ฐฎ๊ฐ€์ง€๋กœ Example Value๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

7) siteid ๊ฐ’์„ ์œ„์—์„œ ์ƒ์„ฑํ•œ ๊ฐ’(camomile)์œผ๋กœ ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.

8) roomid ๊ฐ’์„ room1/camomile ์œผ๋กœ ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.

9) Try it out! ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜์—ฌ API๋ฅผ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค.

deployRBS08

Try it out! ๋ฒ„ํŠผ์„ ํด๋ฆญํ•œ ํ›„์— ์•„๋ž˜์ฒ˜๋Ÿผ response ์ฝ”๋“œ๊ฐ€ 200์œผ๋กœ ๋‚˜ํƒ€๋‚˜๋ฉด ์ •์ƒ์ ์œผ๋กœ ์ฒ˜๋ฆฌ๋œ ๊ฒƒ ์ž…๋‹ˆ๋‹ค.

deployRBS09

์ด ๋‹จ๊ณ„์—์„œ ์ž‘์—…ํ•œ ๋‚ด์šฉ์„ ํ™•์ธํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

  • ์‚ฌ์ดํŠธ ์ƒ์„ฑ์„ ํ…Œ์ŠคํŠธ ํ•˜๋ ค๋ฉด Site API์— ์žˆ๋Š” GET /site/list๋ฅผ ํด๋ฆญํ•˜๊ณ  Try it out!์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.
  • ๋ฃธ ์ƒ์„ฑ์„ ํ…Œ์ŠคํŠธ ํ•˜๋ ค๋ฉด Site API์— ์žˆ๋Š” GET /site/room์„ ํด๋ฆญํ•˜๊ณ  Parameters ์„น์…˜์˜ siteid์— ์‚ฌ์ดํŠธ ์•„์ด๋””(camomile)๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค. ๋งˆ์ฐฎ๊ฐ€์ง€๋กœ Try it out!์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

2.3 ChatBot์—๊ฒŒ ์˜ˆ์•ฝ ์š”์ฒญํ•˜๋ฉด ์‹œ์Šคํ…œ์— ์˜ˆ์•ฝ ์ƒ์„ฑํ•˜๊ธฐ

์ด ๋‹จ๊ณ„์—์„œ๋Š” ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•˜์—ฌ ๋Œ€ํ™” ์„œ๋น„์Šค – ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ – ์˜ˆ์•ฝ์‹œ์Šคํ…œ์„ ๋ชจ๋‘ ์—ฐ๋™ํ•˜์—ฌ ํ•˜๋‚˜์˜ ํ”Œ๋กœ์šฐ๋ฅผ ์™„์„ฑํ•ฉ๋‹ˆ๋‹ค.

2. ๋‚ด๊ฐ€ ๋งŒ๋“  ์ฑ„ํŒ… ์„œ๋น„์Šค๋ฅผ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์œผ๋กœ ๋…ธ์ถœํ•˜๊ธฐ ํŠœํ† ๋ฆฌ์–ผ์—์„œ ์ž‘์„ฑํ•œ ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค. Tutorial 2๋ฅผ ์™„๋ฃŒํ•˜์ง€ ๋ชปํ•˜์‹  ๋ถ„์€ Tutorial3 Start Code Branch๋ฅผ Checkoutํ•˜์—ฌ ์ง„ํ–‰ํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฝ”๋“œ๋ฅผ ์ƒˆ๋กœ Cloneํ•˜๋Š” ๊ฒฝ์šฐ npm install ๋ช…๋ น์„ ๋‹ค์‹œ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ฒƒ์„ ์žŠ์ง€ ๋งˆ์‹ญ์‹œ์˜ค.

git checkout tutorial3
npm install

2.3.1 ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์ถ”๊ฐ€ํ•˜๊ธฐ

๋จผ์ € ์œ„์—์„œ deployํ•œ Simple RBS์˜ REST ์„œ๋น„์Šค url์„ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. REST Service Url์€ https://{rbs-project-name+bluemix-domain}/api/smr/v1 ์ž…๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ๋“ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

http://simple-rbs-camomile-project.eu-gb.mybluemix.net/api/smr/v1

์ด URL์„ .env ํŒŒ์ผ์— ์ €์žฅํ•˜์—ฌ ํ™˜๊ฒฝ๋ณ€์ˆ˜๋กœ ์‚ฌ์šฉํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

# RBS(Room Reservation Service) URL
RBS_URL=http://simple-rbs-camomile-project.eu-gb.mybluemix.net/api/smr/v1

2.3.2 ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ˆ˜์ •ํ•˜๊ธฐ

์ด๋ฒˆ์—๋Š” ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์ด Simple RBS๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

1) ํ•„์š”ํ•œ ๋ชจ๋“ˆ import ํ•˜๊ธฐ

/api/message.js ์ƒ๋‹จ์— ๋‹ค์Œ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

const request = require('request');
const moment = require('moment');

2) checkAvailability() ํ•จ์ˆ˜์— ๋กœ์ง ์ถ”๊ฐ€ํ•˜๊ธฐ
checkAvailability() ํ•จ์ˆ˜์— ์•„๋ž˜ ๋กœ์ง์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. checkAvailability() ํ•จ์ˆ˜๋Š” ํŠน์ • ์‹œ๊ฐ„์— ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ room์„ ๊ฒ€์ƒ‰ํ•˜๊ธฐ ์œ„ํ•œ ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค. /freebusy/available api๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด room์„ ํŠน์ • ์ง“์ง€ ์•Š๊ณ  ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ฐฉ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์ง€๋งŒ ์ด ํŠœํ† ๋ฆฌ์–ผ์—์„œ๋Š” ๋ฐฉ์ด 1๊ฐœ ๋ฟ์ด๊ธฐ์— /freebusy/room api๋ฅผ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.

let checkAvailability = (data, action) => {

  // Context๋กœ๋ถ€ํ„ฐ ํ•„์š”ํ•œ ๊ฐ’์„ ์ถ”์ถœํ•ฉ๋‹ˆ๋‹ค.
  let date = action.dates;
  let startTime = action.times[0].value;
  let endTime = action.times[1]?action.times[1].value:undefined;

  // ๋‚ ์งœ ๊ฐ’๊ณผ ์‹œ๊ฐ„ ๊ฐ’์„ ์กฐํ•ฉํ•˜์—ฌ ์‹œ์ž‘ ์‹œ๊ฐ„๊ณผ ์ข…๋ฃŒ ์‹œ๊ฐ„์„ Timestamp ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ํŽธ์˜๋ฅผ ์œ„ํ•ด ์ข…๋ฃŒ ์‹œ๊ฐ„์ด ๋”ฐ๋กœ ๋ช…์‹œ๋˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ ์‹œ์ž‘ ์‹œ๊ฐ„์—์„œ 1์‹œ๊ฐ„ ํ›„๋กœ ์„ค์ •ํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.
  let startTimestamp = new moment(date+"T"+startTime+"+0900");
  let endTimestamp = new moment(startTimestamp).hours(startTimestamp.hours() + 1);
  if(endTime){
    endTimestamp = new moment(date+" "+endTime);
  }
  
  // roomid๋Š” ํŽธ์˜์ƒ ํ•˜๋“œ์ฝ”๋”ฉ ํ•ฉ๋‹ˆ๋‹ค.
  let roomid = 'room1/camomile';

  // /freebusy/room์€ roomid, start, end ๊ฐ’์„ query parameter๋กœ ๋ฐ›์•„ ํ•ด๋‹น ๋ฃธ์˜ ๊ฐ€์šฉ์„ฑ์„ ๋ฆฌํ„ดํ•˜๋Š” api์ž…๋‹ˆ๋‹ค.
  let reqOption = {
    method : 'GET',
    url : process.env.RBS_URL + '/freebusy/room',
    headers : {
      'Accept': 'application/json',
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    qs : {
      'roomid' : roomid,
      'start' : startTimestamp.valueOf(),
      'end' : endTimestamp.valueOf()
    }
  };
  
  return new Promise((resolved, rejected) => {
    request(reqOption, (err, res, body) => {
      if(err){
        rejected(err);
      }
      body = JSON.parse(body);


      // body.freebusy ์˜ length๊ฐ€ 0๋ณด๋‹ค ํฌ๋ฉด ๊ธฐ์กด์— ์˜ˆ์•ฝ์ •๋ณด๊ฐ€ ์žˆ๋‹ค๋Š” ์˜๋ฏธ๋กœ ํ•ด๋‹น ์‹œ๊ฐ„์— ๋ฃธ์ด ์ด๋ฏธ ์˜ˆ์•ฝ๋˜์–ด ์žˆ์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๊ฒŒ ์•„๋‹ˆ๋ผ๋ฉด ํ•ด๋‹น ๋ฃธ์€ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์ƒํƒœ์ž…๋‹ˆ๋‹ค.
      if(body.freebusy && body.freebusy.length > 0){
        data.output.text = "Rooms are not available at the requested time. Please try again."
      }
      else{
        data.output.text = roomid + " is available. Would you confirm this reservation?"
      }

      resolved(data);
    })
  });
}

3) confirmReservation() ํ•จ์ˆ˜์— ๋กœ์ง ์ถ”๊ฐ€ํ•˜๊ธฐ
confirmReservation() ํ•จ์ˆ˜์— ์•„๋ž˜ ๋กœ์ง์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. confirmReservation() ํ•จ์ˆ˜๋Š” ์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ confirm์„ ๋ฐ›๊ณ  ์‹ค์ œ๋กœ room์„ ์˜ˆ์•ฝ ํ•˜๋Š” ๊ธฐ๋Šฅ์„ ํ•ฉ๋‹ˆ๋‹ค.

let confirmReservation = (data, action) =>{

  // context์—์„œ ํ•„์š”ํ•œ ๊ฐ’์„ ์ถ”์ถœํ•ฉ๋‹ˆ๋‹ค.
  let date = action.dates;
  let startTime = action.times[0].value;
  let endTime = action.times[1]?action.times[1].value:undefined;

  // user ์ •๋ณด๋Š” action ์ •๋ณด์— ๋‹ด๊ฒจ์žˆ์ง€ ์•Š์œผ๋ฏ€๋กœ data์—์„œ ์ถ”์ถœํ•ฉ๋‹ˆ๋‹ค.
  let user = data.context.user;

  let startTimestamp = new moment(date+"T"+startTime+"+0900");
  let endTimestamp = new moment(startTimestamp).hours(startTimestamp.hours() + 1);
  if(endTime){
    endTimestamp = new moment(date+" "+endTime);
  }

  // ํŽธ์˜๋ฅผ ์œ„ํ•ด site, room, purpose ๋ฐ attendees ์ •๋ณด๋Š” ํ•˜๋“œ์ฝ”๋”ฉ๋˜์–ด์žˆ์Šต๋‹ˆ๋‹ค.
  let reqOption = {
    method : 'POST',
    url : process.env.RBS_URL + '/book',
    headers : {
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    },
    json : {
      "roomid": 'room1/camomile',
      "start" : startTimestamp.valueOf(),
      "end" : endTimestamp.valueOf(),
      "purpose": "quick review",
      "attendees": 5,
      "user" : {
        "userid": user.id
      }
    }
  };

  return new Promise((resolved, rejected) => {
    request(reqOption, (err, res, body) => {
      data.context.action = {};
      if(err){
        data.output.text = "Your reservation is not successful. Please try again."
        resolved(data);
      }
      resolved(data);
    })
  });
}

4) getConversationResponse() ํ•จ์ˆ˜ ์ˆ˜์ •ํ•˜๊ธฐ
์œ„ ๋‹จ๊ณ„์—์„œ ์ž‘์„ฑํ•œ ํ•จ์ˆ˜๋Š” http call์„ ํฌํ•จํ•˜๊ณ  ์žˆ์–ด์„œ ๋ฐ”๋กœ ๊ฐ’์„ ๋ฆฌํ„ดํ•˜์ง€ ์•Š๊ณ  Promise ๊ฐ์ฒด๋ฅผ ๋ฆฌํ„ดํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด์— ๋”ฐ๋ผ getConversationResponse()ํ•จ์ˆ˜๋„ ๋ณ€๊ฒฝ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

let getConversationResponse = (message, context) => {
  let payload = {
    workspace_id: process.env.WORKSPACE_ID,
    context: context || {},
    input: message || {}
  };

  payload = preProcess(payload);

  return new Promise((resolved, rejected) => {
    // Send the input to the conversation service
    conversation.message(payload, function(err, data) {
      if (err) {
        rejected(err);
      }
      else{
        
        let processed = postProcess(data);
        if(processed){
          // return ๊ฐ’์ด Promise ์ผ ๊ฒฝ์šฐ
          if(typeof processed.then === 'function'){
            processed.then(data => {
              resolved(data);
            }).catch(err => {
              rejected(err);
            })
          }
          // return ๊ฐ’์ด ๋ณ€๊ฒฝ๋œ data์ผ ๊ฒฝ์šฐ
          else{
            resolved(processed);
          }
        }
        else{
          // return ๊ฐ’์ด ์—†์„ ๊ฒฝ์šฐ
          resolved(data);
        }
        
      }
    });
  })
}

2.3.4 Timezone ์„ค์ • ํ™•์ธ

Watson conversation์— timezone์„ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ context์— timezone ๊ฐ’์„ ์ €์žฅํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.
์„ค์ •ํ•  ์ˆ˜ ์žˆ๋Š” Timezone ๊ฐ’์€ ๋งํฌ๋ฅผ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค.

์ด ์˜ˆ์ œ์—์„œ๋Š” ํด๋ผ์ด์–ธํŠธ ์‚ฌ์ด๋“œ์—์„œ Timezone์„ ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.
ํ”„๋กœ์ ํŠธ์˜ root ๋””๋ ‰ํ† ๋ฆฌ ๋ฐ‘์— ์žˆ๋Š” /public/js/api.js๋ฅผ ์—ด์–ด sendRequest ํ•จ์ˆ˜๋ฅผ ํ™•์ธํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ํƒ€์ž„์กด์„ ๊ฐ•์ œ๋กœ ์„ค์ •ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

payloadToWatson.context.timezone = "Asia/Seoul";

2.3.5 ๋กœ์ปฌ์—์„œ ํ…Œ์ŠคํŠธ ํ•˜๊ธฐ

์œ„์—์„œ ์ž‘์„ฑํ•œ ์ฝ”๋“œ๋ฅผ ๋กœ์ปฌ์—์„œ ํ…Œ์ŠคํŠธ ํ•ฉ๋‹ˆ๋‹ค. Command ์ฐฝ์„ ์—ด์–ด ํ”„๋กœ์ ํŠธ ํด๋”๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.

request ๋ชจ๋“ˆ์„ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

npm install request --save

์•„๋ž˜ ๋ช…๋ น์„ ํ†ตํ•ด ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์‹œ์ž‘์‹œํ‚ต๋‹ˆ๋‹ค.

npm start

์•„๋ž˜์ฒ˜๋Ÿผ ๋Œ€ํ™”๋ฅผ ํ†ตํ•ด ์˜ˆ์•ฝ์„ ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

test_local

์ด์–ด์ง€๋Š” ํฌ์ŠคํŒ…์€

bluemix/watsonservice/2017/02/19/watsonchatbot-4-watson-conversation/”>Watson์œผ๋กœ ์‰ฝ๊ฒŒ ๋งŒ๋“œ๋Š” ์นด์นด์˜คํ†ก ChatBot 4. Node.js ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์นด์นด์˜คํ†ก๊ณผ ์—ฐ๋™ํ•˜๊ธฐ

์ž…๋‹ˆ๋‹ค.