superscriptjs / superscript

A dialogue engine for creating chat bots
http://superscriptjs.com
MIT License
1.65k stars 209 forks source link

Replies not being discarded #389

Open dufia opened 7 years ago

dufia commented 7 years ago
+ Hi *
- Hey!
- Hi, good to see you!
- Hey, welcome back!
- Hello to you too!

In this simple example if you type "Hi" again and again you can get the same replay even three times in a row. This isn't working as expected I presume.

I am testing on a the latest master (1.1.3) mongo 3.4.10, node v6.8.1

LucienBrule commented 6 years ago

I don't believe it's super clear in the documentation yet, but on further inspection, any gambits (reply pairings of +-) at the root level in superscript are kept (with {keep}) implicitly and are placed in the random topic. To discard the a response one needs to create a topic (without {keep}) then place the gambit inside (with {ordered}). Here's an example I got to work just now:

> topic greeting (Hello, name)
  + {ordered} Hello
  - Howdy!
  - Bounjour.
  - Allo
  - Hola
  - Suh
  - We've said hello already
< topic

> topic random
  + Hello
  - Switching to greeting topic {topic=greeting} ^respond("greeting")
< topic

So here you'll get "Switching to random topic Howdy!" from random.Hello, followed by all of the responses in Greeting.Hello on subsequent "Hello"s submitted from a client.

I hope that helps!