miguelgrinberg/Flask-SocketIO-Chat

#question: adapting your example to a chatbot server

alexDeCastroAtGit opened this issue · 3 comments

Hi Miguel, thanks for posting this neat example. I'm flask newbie who's learning the ropes through your tutorials and book.

I have a "back-end" code that takes as input free-form text and classifies the corresponding intent. It's a basic sklearn-kit model.

I'm trying to adapt your code to have a person chatting with the bot (which will have a hard-coded waterfall on top of the ML logic to emulate some basic interaction).

What I'm trying to do (for a prototype) is to have the conversation thread bot-human displayed in a window as per your example -- I'd like messages appended on the same screen.

Do I need to connect the bot the chat room? Any pointers or resources to look at are very welcome.

Anyhow, I'll keep plodding along. Many thanks, Alex

If the chat is between a single client and a server-controlled entity (i.e. your bot), you do not need to use rooms. The server can send a message directly to any client, by simply using the session id of the client as the room name. This is the request.sid argument that you get when you are handling an event from the client. Typically people capture request.sid in the connect event handler and associate it with the user in a database.

Thanks! I'll give it a shot today. Consider this issue closed.

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.