Need help to Tracking conversation state Example

Hi.

I need a help on this concept… like in my webapp when ever the user navigates to the next page the chatbot conversation starts from the first…Which i don’t want…

I saw a concept like “Persisting Trackers” or “Serialization” in the Rasa core documentation “https://core.rasa.com/state.html” .

Can please provide some suggestions on this problem… and please provide some complete simple examples to understand…

You would have to use e.g. the RedisTrackerStore, however you also need to find a way to assign a user id to a person in your web app and make sure that stays the same even when the user navigates away from the page. Because otherwise there’s no way to know whether this is the same conversation

Thank you for your suggestion … can you please provide simple example … much appreciated…

The user id thing is something you would need to handle on your webapp side, so I can’t really provide a good example for that. You’d need some sort of login option for sure

As for the RedisTrackerStore, you would pass this to the Agent https://github.com/RasaHQ/rasa_core/blob/master/rasa_core/agent.py#L48

Sure… Sorry to confuse you … the user management is already there… Iam looking for Example for RedisTrackStore… Thank you for providing the example… I will go through the above link and i will post the questions if i have any…

Thank you once again!!!

1 Like

Iam able to move little bit forward… With some examples …

Got Success case: Used RedisTrackerStore and i was able to save the information in redis when iam running chatbot directly through command prompt (By using ConsoleChannel)

Python Script :

Failure Case My RasaCore is running on “5005” (Running as a separate process) post in my system and iam trying to capture information by using RasaNLUHttpIntepreter and trying to store that information in the redis but no luck i know iam doing some thing wrong which iam not able to trace that

PythonScript

Please suggest which channel i need use (or) suggest some way to Track the Web Channel

At last i was able to move bit forward… I was able to persist all the requests Http requests in the redis. Code Snippet (Corrections/suggestions are welcome) :

I am also need to capture existing user conversation. Example: user chat with bot, the same user will come the next time bot starts from the first. How continue with existing conversation? how handle this?

@sridhar-v9 And I think there is already for MongoDb a class. So this should be no problem?

Hi,

I used Redis tracking store. To use the redis first we need to install( Python package is available). The Rasa has a predefined class to interact with redis called (RedisTrackerStore) The redis stores the data as key values pairs. the key has to be your AGENT name ( nothing but your user id) .

please refer the below screen shot

In the above screen shot the key is “admin”( Logged in user id) and value is our serialized object.

1 Like

I also set up Reduis now. But I have no GUI to look at data. I just get it in a unreadable hex format I think. Like: "\x80\x03crasa_core.conversation\nDialogue\nq\x00)\x81q\x01}q using redis-cli

Is there a way to read out the trackers in a nice way?

You can try the python redis API to extract the serialised tracker. Check the tracker_store.py code in Rasa to understand how Rasa is storing and retrieving information from redis tracker store.

You mean the redis module for python? I am able right now to save the tracker for my case I think. But what is actual a serialised tracker?

Rasa when they store the tracker object, they are serialising it, creating a pickle file I suppose which is saved in Redis, hence if you need to extract it, you will need to deserialise it

Thanks, I see now.

Or you can just save the tracker as a json. I don’t see the advantages of pickle?

I am not sure about the reason tbh. I saw it in the code. @tmbo can you explain the serialisation?

Hi Akelad,

Could you please help me to get the tracker data in json format. I saved data in mongo that have “sender_id” and " .“tracker” image

@ souvikg10 I am able to extract the data, but how to do in real time. I want to save conversation as user input and bot replied. In mine case i created a script and when i am running it, it is saving data in database. Is there is any way to save data in db on realtime? Thanks in advance

1 Like

You have to pass the tracker_store to your Agent object

_tracker_store = RedisTrackerStore(domain, host=os.environ["REDIS_HOST"])

 _agent = load_agent(cmdline_args.core,
                     interpreter=_interpreter,
                     tracker_store=_tracker_store,
                     endpoints=_endpoints)