questions and answers are a very common pattern in dlalogs, and I am not sure about the “best practice” in doting this with ChatScript.
version #1
The first option is to use rejoinders, such as:
s: (tell me a joke) Do you want a funny joke?
a: (yes) OK, here is a funny joke...
a: (no) OK, here is an unfunny joke...
version #2
Usually, the user can achieve the same effect without being asked. To prevent duplication, we can use labels::
s: FUNNYJOKE (tell me a funny joke) OK, here is a funny joke...
s: UNFUNNYJOKE (tell me an unfunny joke) OK, here is an unfunny joke...
s: (tell me a joke) Do you want a funny joke?
a: (~yes) ^reuse(FUNNYJOKE)
a: (~no) ^reuse(UNFUNNYJOKE)
But this will not work if the user says “tell me a funny joke” right after the bot asks him the question! to handle this, we need to add two more rules:
version #3
s: FUNNYJOKE (tell me a funny joke) OK, here is a funny joke...
s: UNFUNNYJOKE (tell me an unfunny joke) OK, here is an unfunny joke...
s: (tell me a joke) Do you want a funny joke?
a: (~yes) ^reuse(FUNNYJOKE)
a: (~no) ^reuse(UNFUNNYJOKE)
a: (tell me a funny joke) ^reuse(FUNNYJOKE)
a: (tell me an unfunny joke) ^reuse(UNFUNNYJOKE)
That’s seven lines for each yes/no question. Is there a better way to do this, maybe with some macro? I have in mind something like this:
s: (tell me a funny joke) OK, here is a funny joke...
s: (tell me an unfunny joke) OK, here is an unfunny joke...
s: (tell me a joke) ^yesnoquestion ("Do you want a funny joke?", "tell me a funny joke", "tell me an unfunny joke")
The first 2 lines are identical to above. The ^yesnoquestion has 3 parameters: the question text, the “yes” equivalent, and the “no” equivalent.
The only problem is, I don’t know how to build this macro to make these 3 lines equivalent to the above 7 lines…