본문 바로가기
Project/Node.js

[JS] Bot Framework 로 챗봇 만들기 (1) 환경 구성

by @sseyeon_ 2023. 9. 11.
반응형

재취준하다가 챗봇 개발에 관심이 생겨서

Bot Framework 기반, 챗봇 개발을 진행해보았습니다.

제가 못 찾는 건진 몰라도, Bot Framework 를 따라해볼만한 블로그는 없더라 ..

진리의 인도인 >< 유투브를 참고하며, Restaurant Chatbot Service 를 만들어볼게요 ~~!

출처 : https://youtu.be/2o_8R_dVtq0?si=P3insbhxwK2vRvKI

 

 

1. setup

  • VSCode
  • NodeJS (저는 18.17.1 버전 입니다.)

 

 

 

 

 

 

2. 에코 봇 (echo bot) 만들기

  • 생성기를 사용하여 echo bot 을 만들어줍니다.
Ensure your version of npm is up to date.
$ sudo npm install -g npm


Install Yeoman and the generator for JS.
$ sudo npm install -g yo generator-botbuilder


원하는 위치로 이동 후
$ cd 원하는 위치 


Use the generator to create an echo bot.
$ sudo yo botbuilder


서버 실행
$ npm start

 

 

 

 

3. 트러블 슈팅

별 문제 없이 아래의 메시지가 떴다면, 4번으로 넘어가시면 됩니다. 😇

 

 

저의 경우, npm 모듈 없이 다운이 되었는데요 !

이건 vscode 실행 후, 해당 터미널에서 npm을 따로 설치해주면 되어서 큰 문제가 되진 않았습니다.

아래는 $ sudo yo botbuilder 후, 나타난 메시지 입니다.

 

  • vscode 실행 후, 진행한 명령어
    $ sudo npm install
    $ sudo npm audit fix --force

 

  • 이후 $ npm start 를 입력했는데 또다시 에러가 발생했습니다 !
 seyeon-ui-MacBookPro rrbot % npm start                 

> RRBOT@1.0.0 start
> node ./index.js

/Users/jeongseyeon/Desktop/portfolio/rrbot/node_modules/restify/lib/request.js:848
    Request.prototype.closed = function closed() {
                             ^

TypeError: Cannot set property closed of #<Readable> which has only a getter
    at patch (/Users/jeongseyeon/Desktop/portfolio/rrbot/node_modules/restify/lib/request.js:848:30)
    at Object.<anonymous> (/Users/jeongseyeon/Desktop/portfolio/rrbot/node_modules/restify/lib/server.js:33:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at Object.<anonymous> (/Users/jeongseyeon/Desktop/portfolio/rrbot/node_modules/restify/lib/index.js:10:14)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)

Node.js v18.17.1


node js 18 버전에서 발생하는 에러로 https://github.com/restify/node-restify/issues/1925 의 댓글을 보고 해결했습니다.

 

[ 해결 방법 ] 

$ sudo npm remove restify
$ sudo npm i restify

 

 

이후 시도하는 $ npm start 는 잘 동작함을 확인할 수 있었습니다.

 

 

 

 

4. Bot Framework Emulator 사용하기

  • 다운받은 Bot Framework Emulator 를 실행시켜줍니다.
    가운데에 Open Bot 버튼을 눌러 Bot Emulator를 만듭시다 !

 

 

  • 다음과 같이 봇 환경설정을 해줍니다.

 

 

  • 참고로 3978 포트의 출처는 index.js의 28 라인 입니다.

 

 

  • 봇이 만들어졌으면, 메시지를 날려봅니다.
    내가 친 메세지를 고대로 리턴해주는 에코 봇이 완성되었습니다 !

 

 

 

여기까지 개발에 필요한 환경 구성은 완료되었고,

다음 포스팅에서는 에코 봇을 커스텀 해보는 과정을 정리해보겠습니다.

 

 

반응형