How to get user input and store them into training data

How can we store input from user ? If bot is unable to answer some question then that question should be stored into data and nxt time we can train the data with its answer so that bot will learn

You can log the conversation to your database, Redis or inmemory storage, which you can access later. The whole conversation will be logged. Tracker Stores

Use logging. Save the conversation in Mongotrackerstore which sends to mongodb

Retrieve data from mongodb. And add them in your data file

But what if I want to directly add it to nlu.md file ? under some intent ?

Use dialoguestate tracker. Using custom action you can add to the training data directly. Even with the help of agents you can do that.

1 Like

Can you please elaborate . how can we use dialogue state tracker ?

from rasa_core.trackers import EventVerbosity

tracker = agent.tracker_store.get_or_create_tracker(s_id)

state = tracker.current_state(event_verbosity = EventVerbosity.ALL)

print(state)

1 Like

Actually my concern is little bit different. ultimately what I want to do is to collect the user input that lead to fallback, so that i could further train the model with that data

Once you’ve logged the conversations to DB you can use that to retrain. I don’t think you can directly add those phrases to the nlu.md file. You’ll have to identify and manually add the examples there or use interactive learning with those new phrases.

He can write a custom code to directly add those inputs from the tracker to nlu.md file.

I was thinking to write code in action.py which can directly write that user input into some ##intent:unknown . I dont known whether there is any better approach. Please do suggest.

1 Like

Dont use custom action as it will go as per the story what if the user lefts the conversation in the middle? Use tracker to get the conversation. The best way is to get the conversation from tracker current state and export it to .md file.

1 Like

Even if you write it this way, you’d have to re-train the NLU again right? I don’t think it trains on the fly.

Hello friend,Could you please tell me how are you fetching specific details from the tracker store. Elaborating my doubt below:

in my run_app.py (socketIO class) i have used mongotracker like this-

db = MongoTrackerStore(domain=“d.yml”,host=‘host ip’, db=‘xyz’, username=“x”,password=“x”,collection=“x”,event_broker=None)

agent = Agent.load(‘models/dialogue’, interpreter=‘models/current/nlu’,action_endpoint = action_endpoint,tracker_store=db)

now i want to fetch some data like db.sender_id or db.event. the reason of doing it is to store it column wise on my mongodb.Please help me solving this problem.

Hello , i get your point . See when bot is unable to handle any input , it’s because NLU has failed . If you would have added fallback policy while training you dialogue model , that will just solve your problem . So if the accuracy is below the predefined threshold of fallback policy , fallback action will trigger . Within fallback action get the latest message ( via “tracker.latest_message[‘text’]” ) and since you know it was because of this input fallback is triggered , definitely this input has failed for NLU .Then you can just write log or even a simple text file to save all those inputs . Hope it helps :slight_smile:

How do we access the Inmemorystorage?

Can you please elaborate or share a repository if you were successful in the extraction?

1 Like

Continuing the discussion from How to get user input and store them into training data:

hi, i have the same issue with you too and also would like to know how collect user input into a file so i can retrain it if it doesn’t belong to any correct/not existing intent. you figure the way of doing this? thanks

Hi all. I am new to rasa. I want to grab the user’s input and validate it in the backend in actions.py. So how do I store the input given by user in a variable without using entity or slots and use that in actions.py. @srikar_1996 @jeng @Abir @visam @ajaxwini @Ajinkz @akelad @Juste @juste_petr

Continuing the discussion from How to get user input and store them into training data

Hi Ajinkz, Have u found the solution for this issue. i am also came across with this. please give me the details

Thanks,
Ramya