-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Saving state #46
Comments
To export user data to a JSON serializable format, call getUservars() and then to put their variables back in, call setUservars(). You can persist the data however you like (e.g. write JSON files to the hard disk; put them into a SQL database; etc.) |
You are referring to user variables. I'm also interested in conversation status. For example if the bot says today:
I want to allow a user to reply tomorrow:
This is not going to work if in the meantime I want to deploy a new version of the bot brain, as this resets the chat history. Is that correct? This is a real deal beaker if someone wants to maintain the conversation flow for long time periods. Any idea/suggestion ? |
That should still work. Part of the user data includes the recent input and reply history; the reply history is used when processing the Example output of
|
That should work, thanks. |
That's an exercise for the reader. ;) The library gives you the tools to import/export user variables, but it's up to your actual bot implementation to work out the details of where/when/how to persist them (see scope). For example, some people would be fine with data being saved to disk as JSON files, others would want it to go into a MySQL database instead, then others would want Postgres instead of MySQL, etc., so the library doesn't concern itself with such things. |
Thanks for clarifying this. |
Can you provide (or point me to) a working get/set user var example? It's not clear to me what is the purpose of |
I don't have a Node example, but here's a couple examples of doing the same thing in Perl:
The basic logic is:
The rs.reply("user", "my name is alice");
console.log(rs.getUservar("user", "name")); // "Alice"
rs.freezeUservars("user");
rs.reply("user", "my name is bob");
console.log(rs.getUservar("user", "name")); // "Bob"
rs.thawUservars("user", "thaw");
console.log(rs.getUservar("user", "name")); // "Alice" again. |
I've added an example of persisting user data to disk as JSON files to the https://github.com/aichaos/rivescript-js/tree/master/eg/persistence |
👍 |
Sorry for the noob questions..
Is there a way to save the state? It seems that when restarting the application the state (topics, variables) is lost. This does not allow for hot upgrades
The text was updated successfully, but these errors were encountered: