@markdown
# Bot Framework으로 간단한 챗봇 만들기
- Heroku, python-3.6, microsoftbotframework 패키지 사용
## Bot Framework
____
- 간단하게 챗봇을 만들 수 있는 Microsoft사의 Bot Framework
- 격리된 대화를 위한 로직 구현 가능
- Bot Builder SDK로 C++, Node.js, REST API 지원
- 다양한 채널(페이스북 메신저, 텔레그램, Skype 등) 연동 기능
### Bot Framework 등록
- [https://dev.botframework.com/bots](https://dev.botframework.com/bots) 로그인
![](https://user-images.githubusercontent.com/12658717/29805606-b096a12c-8cc5-11e7-97f0-eb6eff8b42d3.png)
- `Create a bot` 클릭하여 만들 Bot 기본 정보를 입력한다.
![](https://user-images.githubusercontent.com/12658717/29805627-ddcfe158-8cc5-11e7-8286-cb723efef0ee.png)
- 중간에 Microsoft App ID와 Password를 생성하고 `Configuration` 정보를 반드시 채워준다.
## python 사용한 Bot 로직 구현
____
- Bot을 배포하기 위해서는 필요한 파일들이 있다.
`Procfile`, `config.yaml`, `main.py`, `requirements.txt`, `runtime.txt`, `tasks.py`
소스코드 - [https://github.com/KSLEE7746/MyChatBot](https://github.com/KSLEE7746/MyChatBot)
> [https://github.com/Grungnie/microsoftbotframework](https://github.com/Grungnie/microsoftbotframework)를 참고하여 소스코드 작성함
- 작성한 소스코드를 자신의 Github에 업로드하여 준비해둔다.
## Heroku
____
- Heroku는 dyno라는 작은 리눅스 가상 서버를 제공해서 개발자가 만든 애플리케이션을 빌드, 실행하고 스케일링할 수 있게 해준다.
- bot 로직이 구현된 python 실행할 Application을
- Github를 통해 배포하게되면 commit하는 것만으로 Application을 재배포 할 수 있다는 장점이 있다.
### Heroku에 python 배포하기
- [https://dashboard.heroku.com/apps](https://dashboard.heroku.com/apps) 가입 후 로그인
- `Create New App` 클릭 후 앱 이름 작성하여 생성
![](https://user-images.githubusercontent.com/12658717/29806474-6b162794-8cca-11e7-990b-5a62e9c50d93.png)
- Github 클릭하여 위에서 작성한 프로젝트와 Heroku를 연결한다.
![](https://user-images.githubusercontent.com/12658717/29806559-ed7cacf8-8cca-11e7-9ac0-fb9181560afc.png)
- `Disable Automaitc Deploys`, `Deploy Branch` 클릭하여 배포를 마무리한다.
![](https://user-images.githubusercontent.com/12658717/29806629-5a01ecb2-8ccb-11e7-93aa-418048b808dd.png)
- `Open app` 클릭하여 나타나는 새창의 주소를 복사한다.
![](https://user-images.githubusercontent.com/12658717/29806705-b6bc580c-8ccb-11e7-9051-88e34f05370e.png)
<br/>
### BotFramework End point 설정
- 자신의 url/api/messages를 BotFramework - settings - Configuration - Messaging endpoint에 입력한다.
![](https://user-images.githubusercontent.com/12658717/29806767-feadf9cc-8ccb-11e7-9a31-34b29260a246.png)
- `Test`를 눌러 구현한 채팅 로직을 테스트 한다.
'Bot 기술노트' 카테고리의 다른 글
웹페이지 게시물 업데이트 알람 봇 만들기(2) (0) | 2019.07.14 |
---|---|
웹페이지 게시물 업데이트 알람 봇 만들기(1) (12) | 2019.07.11 |
BotFramework Rest API로 사용하기 (0) | 2017.08.30 |
python - tweepy 사용한 트위터 크롤링(crawling) (10) | 2017.08.05 |