Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to receive case-insensitive arguments in rivescipt #312

Open
hark444 opened this issue Jun 3, 2019 · 3 comments
Open

how to receive case-insensitive arguments in rivescipt #312

hark444 opened this issue Jun 3, 2019 · 3 comments

Comments

@hark444
Copy link

hark444 commented Jun 3, 2019

I want to change a password through a service called by RiveScript.
So, while getting the current password from user, RiveScript converts everything to lowercase.

Is there anyway we can retrieve case-insensitive arguments in RiveScript.

@dcsan
Copy link
Contributor

dcsan commented Jun 4, 2019

if you look back in the issues there was a lot of discussion on this. generally for 99% of chatbot inputs, we had a problem where content authors would type case sensitive things and it wouldn't match.

+ I don't know
- why not?

rivescript expects all triggers to be in lower case so the capitalized I would not match.
I can't recall where this finally ended up but the use case of passwords seems like an edge case...

@hark444
Copy link
Author

hark444 commented Jun 4, 2019

@dcsan Thanks for the response. Is there a work-around for this?

@kjleitz
Copy link
Contributor

kjleitz commented Aug 2, 2019

@hark444 In my project, I capture the input first (before giving it to the RS engine) and set it as a uservar before having the engine reply. Since a uservar can be set with persistent case, you can then access it in RiveScript later as a case-sensitive string. I don't know if it's sufficient for your use case, but, as a very simple example:

someInputElement.addEventListener('change', (event) => {
  const message = event.target.value;
  engine.setUservar('kjleitz', 'originalmessage', message);
  engine.reply('kjleitz', message);
});

engine.setSubroutine('check-password', (_rs, [password, ..._args]) => {
  // 'pAs$w0RD' would normally be turned into 'pasw0rd' if you passed it via <star>,
  // but if you pass it via <get originalmessage> it'll keep the caps and special chars
  return password === 'pAs$w0RD';
});
+ let me in
^ Okay, what is the password?

+ *
% okay what is the password
* <call>check-password <get originalmessage></call> == true => Come on in!
- WRONG!

user: Let me in!
bot: Okay, what is the password?
user: pAs$w0RD
bot: Come on in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants