Skip to content

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

Open

Description

@elpimous

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 ?

Activity

  1. elpimous commented on Jun 18, 2018

    @elpimous
    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 !

  2. elpimous commented on Jun 18, 2018

    @elpimous
    Author

    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
    
  3. kirsle commented on Jun 18, 2018

    @kirsle
    Member

    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.
    
  4. elpimous commented on Jun 19, 2018

    @elpimous
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions