I think the current version of chatterbot does support this feature.
Hi @Cosmos19, I don't believe an example for this has been included. You can do this by passing a unique identifier to the chat bot when getting a response. For example:
unique_id = 'something_unique'
chatbot.get_response(user_input, unique_id)
Let me know if you have any questions or if there is anything you I clarify.
Hi @gunthercox Thanks for your quick reply.
I have done that. But am facing below error.
C:\Python27\lib\site-packages\chatterbot\chatterbot.py", line 119,
AttributeError: 'NoneType' object has no attribute 'conversation'
version: chatterbot-0.6.1
@Cosmos19 because there is no session with your unique_id, instead you could try to create a separate session for conversation, I think this line will help how to create sessions https://github.com/gunthercox/ChatterBot/blob/master/chatterbot/chatterbot.py#L75
@vkosuri I have tried this. But still same error.
Here is my code.
self.chatbot.conversation_sessions = ConversationSessionManager()
self.chatbot.unique_session = self.chatbot.conversation_sessions.new()
self.chatbot.unique_session.id = '234.1.34.56'
statement = self.chatbot.get_response(message,self.chatbot.unique_session.id)
@Cosmos19 I think if you specific question about how to do this, please post your question in stack-overflow https://github.com/gunthercox/ChatterBot/issues/703 with https://stackoverflow.com/questions/tagged/chatterbot tag, hope you will get more responses.
Instead asking question here make use of stack-overflow, this issues tracker is meant only for Chatterbot issues.
@gunthercox Any inputs?
@Cosmos19 You don't need to worry about re-posting your question on Stack Overflow. You have already asked it here and I will make sure that it gets answered if possible.
There is actually an existing example that is used in ChatterBot's codebase. In one of the default Django views (typically only used when one is using ChatterBot with Django), a new session is created for different users that visit the site. I believe the code from the view may provide an additional example that would be helpful. https://github.com/gunthercox/ChatterBot/blob/master/chatterbot/ext/django_chatterbot/views.py
I believe the error that you are encountering is because a session id needs to be created by the chat bot before it can be used. You can create a new session like this:
chat_session = self.chatterbot.conversation_sessions.new()
Then, if you save the session somewhere, you can use the id later when you need to access it again like this:
response = chatbot.get_response(input_data, chat_session.id_string)
I just found this repo and I wanted to give @gunthercox a million thanks not only for your work here, but also for being supportive, something I saw just going through your answers, like the above for instance. Great to see this!
@gunthercox AttributeError: 'ChatBot' object has no attribute 'conversation_sessions'
This error occured. I remember few months ago i can use this when i try. But now this happen, am i missed something?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@Cosmos19 You don't need to worry about re-posting your question on Stack Overflow. You have already asked it here and I will make sure that it gets answered if possible.
There is actually an existing example that is used in ChatterBot's codebase. In one of the default Django views (typically only used when one is using ChatterBot with Django), a new session is created for different users that visit the site. I believe the code from the view may provide an additional example that would be helpful. https://github.com/gunthercox/ChatterBot/blob/master/chatterbot/ext/django_chatterbot/views.py
I believe the error that you are encountering is because a session id needs to be created by the chat bot before it can be used. You can create a new session like this:
Then, if you save the session somewhere, you can use the id later when you need to access it again like this: