파이썬에서 chatbot을 성공적으로 구현했습니다. HTTP 응답에 대해 api.ai를 호출하고 기본적으로 원하는 섹션을 가져 오는 값을 파싱했습니다. 문제는 내가 진행중인 대화를 원한다는 것입니다. 예를 들어 내가 인사했다고 가정 해 보겠습니다. 로봇이 인사하고 파이썬 코드가 처음 실행 된 후 다시 실행해야합니다.채팅 봇과 진행중인 대화를 나누는 방법은 무엇입니까?
파이썬 코드를 한 번만 실행하면 얼마나 많은 요청을 보내고받을지라도 실제로 원하는 것은 봇과 대화하는 것입니다.
# Initialize your program, lots of code here, get token/id, setup other variables
def process_input(input_text):
# clean input text
# get response from web bot
response = requests.get('url')
# clean response and then print it/redirect it
return response
if __name__=='__main__':
while True:
user_input = raw_input()
print(process_input(user_input))
# also add some terminal conditions like if user types 'bye', break while loop and exit
당신은으로 webhook, 또는 응답을 가져 오는에 대한 별도의 HTTP 요청을 사용하고 - 여기 – Jay
별도의 HTTP 응답 – Jimmy