Remembering Chatbot user in RS

  • 3 Replies


  • Roomba
  • *
  • 1
Remembering Chatbot user in RS
« on: March 19, 2018, 12:21:04 pm »
First time posting. While using rivescript and Javascript is there anyway to save developed variables from a conversation into an object for later use? My intent is to be able to call on the object later in the chat or at least be able to use the rivescript variables in javascript. How can I go about this, very much a noob at this but am fascinated none the less.



  • At the end of the game, the King and Pawn go into the same box.
  • Trusty Member
  • **********************
  • Colossus
  • *
  • 5865
Re: Remembering Chatbot user in RS
« Reply #1 on: March 19, 2018, 06:31:14 pm »
Welcome to AiDreams!

There was a fellow who, several years ago, developed some methods to allow his RiveScript bot to be able to SAVE information and later RECALL it as needed. In other words, he gave it a usable memory. I believe he also had other nice features but it was a bit involved to set up. Unfortunately, when I tried his bookmarked link I'd saved it was broken.

There may be some other users of RiveScript, other than myself, who are doing something similar to this or perhaps Noah Petherbridge might weigh in on this if you inquired at the RiveScript site or thereabouts.

Of all the things I've done with RS,, I'd really like for it to be able to save parts of our conversations for later use.

This would also help keep the bot on target with regard to context and topic flow. Hopefully, someone will chime in.
In the world of AI, it's the thought that counts!



  • Roomba
  • *
  • 2
Re: Remembering Chatbot user in RS
« Reply #2 on: January 16, 2022, 12:49:49 am »
RiveScript creator here, this is an old thread but in case anyone finds it and is curious:

By default RiveScript keeps user variables in running memory but you can use the getUservars and setUservars functions to export and import them, so you can save a copy (as JSON data) in between runs of your bot. RiveScript's original niche is in being a long-running process with a bot loaded in memory able to remember you from one reply to the next. Some general strategies:

* Your program should initialize RiveScript once (loadDirectory, etc.) and enter a "main loop" of awaiting messages to reply to, and it'll keep your variables for the duration of the running session. e.g., if embedded on a web page using rivescript.js the program keeps running while the page is open, until the user reloads or leaves the site, and it will remember them fine during this time.
* For "server side use" if at all possible, still initialize RiveScript once and use that bot instance to handle user requests.

rivescript.js has several examples: look at the persistence and json-server examples in particular.

In more recent years there are alternative user session adapters for some implementations, so you can directly persist variables into a Redis cache making this a whole lot more robust, see the "redis" example at the above link.



  • Eve
  • ***********
  • 1287
Re: Remembering Chatbot user in RS
« Reply #3 on: January 16, 2022, 11:41:03 am »
Thanks for the input.

I think I would insert an optional callback right in the setVariable() function of rivescript.js, and make it available in the public API through a setPersistenceCallback() function, so I (the user) can inject my own persistence callback at initialization.

Welcome to AiDreams :)


Users Online

40 Guests, 0 Users

Most Online Today: 68. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)