Last active
September 7, 2018 07:15
-
-
Save MKtalk/1daac93eab46f3c83f99349254e94dd3 to your computer and use it in GitHub Desktop.
간단한 설문 조사 챗봇을 위한 코드 구현
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import (absolute_import, division, print_function, unicode_literals) | |
from bothub_client.bot import BaseBot | |
from bothub_client.messages import Message | |
from bothub_client.decorators import command, intent | |
class Bot(BaseBot): | |
# /start 시 실행 | |
@command('start') | |
def start_message(self, event, context, content): | |
message = Message(event) | |
message.set_text('아래 버튼을 누르시면 설문 조사를 시작합니다') | |
# quick reply를 통해 bothub.yml에 등록된 intents 중 pools를 실행 | |
message.add_quick_reply("설문을 시작합니다.", '/intent pools') | |
self.send_message(message) | |
# /intent pools 가 정상적으로 완료되면 @intent를 이용해 저장된 값을 불러옴 | |
@intent('pools') | |
def pools_result(self, event, context, answers): | |
q1 = answers.get('question1') # slots id 와 대응 | |
q2 = answers.get('question2') | |
msg = '질문1 답변은 {}, 질문2 답변은 {} 입니다.'.format(q1, q2) | |
self.send_message(msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment