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

variable javascript
 
 

Hi,

I use javascript interpreter, and i want input a javascript variabl in rivscript varibal, how can i do that ?

exemple for cookie :

> object lirecookie javascript
      var id = args[0];
      var nom1 = rs.getUservar(id, “nom1”);
var nameeq = nom1 + “=”;
var ca = [removed].split(’;’);
for(var i=0;i < ca.length;i++) {
var c = ca;
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameeq) == 0) return c.substring(nameeq.length,c.length);
}
return null;
< object

+ recup *
- <set nom1=<star>> <call> lirecookie <id></call>

// exemple user say recup name
// bot say : john

but i want catch this john in <set name= .... >

can i do that ?

i have try
<set name <call><call> lirecookie <id></call>>
but it don’t works

thx.

 

 

 

 
  [ # 1 ]

The <call> tags are processed as the very last ones in a reply, long after the <set> tag has already been handled.

To set a user variable from the JavaScript you can use rs.currentUser() to get the current user’s ID (like the <id> tag from RiveScript), and then setUservar() to set a value.

There’s an example of this included in the default RiveScript files for rivescript-js:

object setvar javascript
 
// Example of how to get the current user's ID and set
 // variables for them.
 
var uid rs.currentUser();
 var 
name  args.shift();
 var 
value args.join(" ");
 
rs.setUservar(uidnamevalue);
object


javascript set to *
Set user variable <star1to <star2>.<call>setvar <star1> <star2></call
 

 
  [ # 2 ]

thank you very much, I’ll try that

 

 
  [ # 3 ]

Hi,

I have a problem. This code doesn’t run on my rivscript version, it must be too old.
I’ll seem silly, but so I downloaded the latest version of rivescript javascript, but this one does not work in local host. is this normal?
Next, when I test your code online that run obviously but what I want to do, it is mostly recover the value of a variable Javascript in the browser and put it in a variable and rs it possible to do that?
Thank you for your answers.

 

 
  login or register to react