miguelgrinberg / Flask-SocketIO-Chat

A simple chat application that demonstrates how to structure a Flask-SocketIO application.
http://blog.miguelgrinberg.com/post/easy-websockets-with-flask-and-gevent
MIT License
676 stars 242 forks source link

Trying to make a chatbot #14

Closed augustot2 closed 5 years ago

augustot2 commented 6 years ago

hi, I'm trying to do a chatbot, I already can make it work in a terminal but I would like to develop it in a web front end. I do not know much about web develop, What I would like to know is if it is possible to do something like my code bellow, but in flask socketio.

Here the user ask the bot to show a Painter art, by giving it's name and having the artist's name, it display all it's art names and after been chosen it display in screen.

user_input = " "
while TRUE:
  response = send_message(user_input, context)
  if response['intents'] and response['intents'][0]['intent'] == "user_paint":
    user_input = input(">> ")
    response = send_message(user_input, context)
    context = response['context']
    painter = response['entities']['entity' == "painter_name"]['value']
    #print bot response
    if response['output']['text']:
        print(response['output']['text'][0])
    #get paint description
    user_input = input(">> ")
    response = send_message(user_input, context)
    context = response['context']
    if response['output']['text']:
        print(response['output']['text'][0])
    art_name = response['entities']['entity' == "art_name"]['value']
    show_data(painter_name, paint)
  # Prompt for next round of input.
  user_input = input('>> ')

I'm having trouble thinking how can I do to make a "wait user input " button like "input()" in flask-socketio.

miguelgrinberg commented 6 years ago

Flask-SocketIO is not a UI framework, it can't wait for user input. You need to do that in the web browser, using JavaScript.

augustot2 commented 6 years ago

Thank you for the quick answer, I will try to find other way, i do not know JavaScript, so any idea would be great!

miguelgrinberg commented 5 years ago

This issue will be automatically closed due to being inactive for more than six months. Seeing that I haven't responded to your last comment, it is quite possible that I have dropped the ball on this issue and I apologize about that. If that is the case, do not take the closing of the issue personally as it is an automated process doing it, just reopen it and I'll get back to you.