Discovering QiChat, the SBR language for creating chatbots

Reacting when someone makes an introduction¶

1. Using optionals¶

Now that we've learnt how to say hello, it's time to understand introductions.

u:(my name is ["iron man" "captain america" "{the} hulk" thor "black widow" hawkeye])

Nice to meet you!


The syntax {} defines a list of optional words or phrases. Here "{the} hulk" is equivalent to ["the hulk" hulk]. To define optional phrases, put them within quotes, as you would in a normal list. Please be careful to always embed optionals in a phrase or sentence: using them on their own would allow the robot to match an empty input, which would weaken speech recognition.

2. Using concepts¶

This is a good start, but if you want your robot to understand more names than just the first team of the Avengers, the list is going to get a bit long. In that case, it's good practice to define a concept. A concept is instantiated with concept:(concept_name) and called with ~concept_name.

concept:(avengers_endgame) ["iron man" "captain america" "{the} hulk" thor "black widow" hawkeye "war machine" falcon "sam {wilson}" "bucky {barnes}" spider-man "{the} scarlet witch" quicksilver vision "doctor strange" "black panther" "ant-man" "{the} wasp" "captain marvel" "{nick} fury" star-lord nebula gamora "drax {"the destroyer"}" "rocket {raccoon}" groot]

u:(my name is ~avengers_endgame)

Nice to meet you!


Note: concepts are also useful for inputs that will be used more than once. They can be put in a separate .top file for easier maintenance. This file is traditionally named lexicon, and should be stored in the same folder as the .top file you're working on, so that the concepts are automatically included.

3. Making Pepper remember names¶

Now the robot can understand more superheroes' names, but his answer is still too generic. To make it more personal and show that he understood the user's name, you can use the input storage function with underscore sign _ to catch the value, and $1 to use it, so that Pepper will be able to catch and repeat the human input. concept:(avengers_endgame) ["iron man" "captain america" "{the} hulk" thor "black widow" hawkeye "war machine" falcon "sam {wilson}" "bucky {barnes}" spider-man "{the} scarlet witch" quicksilver vision "doctor strange" "black panther" "ant-man" "{the} wasp" "captain marvel" "{nick} fury" star-lord nebula gamora "drax {"the destroyer"}" "rocket {raccoon}" groot] u:(my name is _~avengers_endgame) Nice to meet you$1 !


This way, if the user says "my name is Iron Man", Pepper will answer "Nice to meet you Iron Man!".

Note: $1 will have the value of the first _ placed in the input. You can use several _ in a given input, and catch their values with$2, $3, etc. Note:$1 is a temporary variable, so it can only be used in the output linked with the input it's placed in. If you want to save its value, assign it to an ALMemory variable: $MyVariable=$1.

Note: always leave a space between the variable and any following punctuation.

4. Using the wildcard¶

Now, if you want the robot to understand any human name, it may be difficult to list them all in a concept. In that case, you can resort to the wildcard (*)

u:(my name is _*)
Nice to meet you \$1 !


Here the wildcard allows you to say anything to the robot without defining a list first. It is very powerful, but it can also degrade the performance of the speech recognition, so use it sparingly, and never alone in a user rule. Plus, it does not always work perfectly and there are still some words that the robot won't understand that way, so it's always preferable to define a list whenever possible.

Note: the use of the wildcard requires a remote connection.