AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Multi user / session support
 
 

Hi,

I’ve been trying to create a server version of RiveScript that will allow multi user / multi sessions, but it would seem that RS does not support this.  As a workaround, I’ve ame up with this approach.

Everytime a session is created, you call the new_instance procedure.

#!/usr/bin/perl
use strict;
use 
warnings;
use 
RiveScript

my %HASH;

$HASH{session1} = &new;_instance;
$HASH{session2} = &new;_instance;

my $message "hello there";
my $reply $HASH{session1}->reply("user"$message);
print 
$reply;

sub new_instance
{
 my $rs 
RiveScript->new();
 
$rs->loadDirectory("./eliza");
 
$rs->sortReplies();
 return 
$rs;

There are two major downsides though.  Everytime a new instance is loaded, it will read all the .rs files again.  If you have a big bot, this could slow things down due to an I/O hit.  Second problem is the amount of memory used, since each instance would effectively be a ful copy (all .rs files, session state, the works) in it’s own variable.

For the next release of RiveScript, it would be good to have an approach where the session state can be defined as an input variable to the reply procedure, so the bot can maintain multi user session state natively.

 

 
  [ # 1 ]

And it turns out Noah already had this feature in it grin

my $reply $rs->reply("user"$message); 

As I was going through the RiveScript.pm script, I noticed that “user” was in fact doing what I wanted it to do.  By changing “user” to the different sessions, the bot responds as if it was a different user.

Good job on the code Noah!  It is nicely written, well put together.

 

 
  [ # 2 ]

Thanks! Glad you got it all sorted out. smile

 

 
  login or register to react