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

Grabbing a variable as the user entered it. 
 
 

Im using RiveScript to interactively ask the user some questions as a setup for a given set of actions. However I need to be able to capture some of the variables just as the user entered them.

For example, If I ask the user for the name of the group and the group name is “Mike’s Group” then I need to capture that with the ’ in it. It appears the pre-processor strips the ’ from the variable before presenting it as <star>.

Is there a way to capture the variable just as the user entered it?

 

 
  [ # 1 ]

It’s not very easy, but what I always recommend people do is:

1. Before you get a reply(), first do like setUservar(username, “origMessage”, message) and store their raw original message.
2. In an object macro you could get it back like: `let origMessage = await rs.getUservar(rs.currentUser(), “origMessage”)` (JavaScript example)
3. And then re-parse it yourself. You’ll have the full, raw, original message so if the user is like “name the chat Mike’s Group” that’s exactly how the origMessage would look—if it matched “+ name the chat *” you’ll have to do your own regexp in the macro to get just the name. Like /^name the chat (.+?)$/

It’s not possible for RiveScript to have an “<ostar1>” tag or something that catches the original contents of wildcards, because the user message that gets tested against the +Trigger regexp has already been formatted, lowercased and stripped.

For some simple use cases (like if you wanted “[brackets]” or an “@” symbol from an email address to stay intact), enabling UTF-8 mode will let most symbols slip through—but not common punctuation like ! ? ; : .—but you can change the punctuation regexp to something else if you want to preserve punctuation, but this might severely impact matching ability. For example, “hello?” does not match “+ hello” if you allow the literal question mark to stay in the message.

 

 
  login or register to react