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

use condition with star (if exist, star reply ; otherwise default reply) #123

Open
elpimous opened this issue Jun 18, 2018 · 4 comments
Open

Comments

@elpimous
Copy link

Hi Noah, hi all,
need to find a way to success :
I try to reduce routine, and find better reply than "catch all trigger"
here is what I'd like to do :

+ what is a *
* @ <star>
- I don't know what it is

+ ball
- a rounded object

If the star correspond to an existing trigger, it speaks it reply
either, it reply specific default reply

Any help ?

@elpimous
Copy link
Author

I did another test :

+ what is a *
@ <star>

+ what is a *
- I don't know what it is

+ ball
- a rounded object

Doesn't work !

@elpimous
Copy link
Author

elpimous commented Jun 18, 2018

found an idea, but perhaps there is simpler !!
I just created a specific catch trigger !

+ what is a *
@ object <star>

+ object *
- I don't know what it is

+ object ball
- a rounded object

@kirsle
Copy link
Member

kirsle commented Jun 18, 2018

Something like this might work: https://play.rivescript.com/s/ss8WgUpO4p

! version = 2.0

// Wildcard replies normally under normal conditions but
// will reply `no-match` when the uservar `testing=true`
+ *
* <get testing> == true => no-match
- I don't know how to reply to that.
- Try asking a different way.

// set testing=true to test the wildcard for a trigger match.
+ what is a *
* <set testing=true><@> != no-match => <@><set testing=false>
- I don't know what it is.<set testing=false>

+ ball
- A rounded object.

+ box
- A square object.

The condition sets the uservar testing=true before redirecting to <star> (<@>)... the catch-all trigger will test if we're testing and say no-match if no match, which is easy for the condition to match on.

This lets the wildcard trigger continue working as normal for when the user says something completely wrong.

Ideally I'd want to have <set testing=false> inside the wildcard condition but it seemed like it didn't process the <set> tag in there. Probably a bug (in the JS version) and Python may not be affected by it, but you may wanna do some experimenting.

Example:

// clean up the `testing` variable after testing it,
// but for the JS edition of RiveScript this didn't
// take hold until the wildcard trigger itself was
// matched directly in a future reply.
+ *
* <get testing> == true => no-match<set testing=false>
- I don't know how to reply to that.
- Try asking a different way.

@elpimous
Copy link
Author

elpimous commented Jun 19, 2018

Wow ! What a complete answer !!
As usual, thanks Noah, for your soft and your support !

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

2 participants