rivescript-python
rivescript-python copied to clipboard
make permanent an option in trigger, without writing it on triggers
Hi Noah, hi all, I continue Alfred s' brain (a physical Alive robot) When I communicate with Alfred, I ofter tell "Alfred", at the beginning or end sentence : How could I tell the program : forget alfred word ??
ex :
+ [alfred] power on the tv [alfred]
I'd like rivescript to ignore this word when i speak it. So I will not have to write it everywere !
Sure I could erase it on python with a replace command, but I'd like to do it under a rive file !
I think you can use default trigger in begin.rive
.
This trigger is matched before other all triggers.
check this tutorial https://www.rivescript.com/docs/tutorial#the-begin-block
> begin
+ request // This trigger is tested first.
- {ok}
< begin
Hi, I tested, and it doesn't work
Something like this maybe:
+ alfred *{weight=100}
- <@>
+ * alfred{weight=100}
- <@>
The high weight value should ensure the trigger gets tested first (unless you have other triggers with weight >100). If it begins or ends with the word "alfred" it just redirects to a trigger without that word.
It may be possible to combine them into one trigger, but using optionals on either end like your original example might backfire: the first iteration you'd match the [alfred] * [alfred]
trigger and it would match whether or not you said the word alfred (because it's optional, you see), and it would redirect to <star>
and it would test [alfred] * [alfred]
first again, and repeat forever.
Perfect, Noah. So simple... Thanks
ps : this test failed
+ [alfred] * [alfred]
- <@>
+ bonjour *
- salut
question : bonjour alfred
[ERR: Deep recursion detected]
This worked :
+ alfred *{weight=100}
- <@>
+ * alfred{weight=100}
- <@>
Hope it will help each other !