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..

object perl in rive script
 
 

Ok, I am sure I am doing this wrong but I have to ask.

End goal is to have the script query an sql database and load that data into a set of user variables in the rive script brain.

I did an early one but it is a single word = desc pair being pulled and I just used a return in the perl script. The new db table will return 10 data points. So after reading some of the docs I though it would be nice to have the object call setUservar and plug the data directly into the rivescript brain.

So I set up a test to try it.

object info perl

my $USER 
$rs->currentUser();
my DATA = (
     
moon => "yes",
     
sun => "no",
    );
my $TEMP;

$TEMP $rs->setUservar($USERDATA);

object

_ [*] cmd *
- <
call>info</call>
the answer to moon is <get sex

Note: the DATA has a % in front of it but that breaks this forum software.

It returns “1the answer to moon is undefined”

What would be the best way to pull the data into user variables in the rivescript brain?

 

 

 
  [ # 1 ]

In your example code, you’re setting user variables moon=“yes” and sun=“no” but in the reply you’re getting the user variable “sex”

Is that a typo?

I think your code should generally work if the user variables are named correctly. You can also try calling getUservars and printing the result of that, i.e. with Data::Dumper.

 

 
  [ # 2 ]

That is a typo in the posted script. It is correct in my script.

Still gives the same output. Im also wondering where the 1 comes from at the beginning of the response.

 

 
  [ # 3 ]

Ok, I have some progress with this code.

object info perl
my $TEMP
;
my $USER $rs->currentUser();
my DATA = (
    
'moon' => 'yes',
    
'sun' => 'no',
    );

$TEMP $rs->setUservar($USERDATA);

object

_ [*] cmd set
- <call>info</call>

_ [*] cmd ans
I have <get sun

by seperating out the cmd to one that sets it and one that returns the answer. It get the following

>: cmd set
MESSAGE: Game User: cmd set
AI: 1
>: cmd ans
MESSAGE: Game User: cmd ans
AI: I have no


Though I am still getting a response of 1 out of the perl object and I have no idea where it is coming from. Actually I suspect it is the boolean response from the setUservar call as it shows to have a boolean response. I just dont know why the $TEMP is not catching it.

 

 
  login or register to react