Discovering QiChat, the SBR language for creating chatbots

Randomizing jokes

Using the "random" function

Pepper now has good manners and shows a respectful and considerate behavior, so it's time for the next step in a good conversation: telling some jokes to make the user laugh!

We have seen how to add more variety into inputs so that the robot can understand better, and how to customize the robot's answer according to what was said. But most outputs cannot resort to repeating the input for variety, and giving always the same answer can be boring.

Lists can be randomized using the function ^rand as follow

u:(tell me a joke)
^rand[
	"You know the one about the vertical bed? It will make your hair stand up straight!"
	"Do you know the difference between roast beef and pea soup? Anyone can roast beef!"
	"Two peanuts were walking down the street and one was a salted."
	"I tried to catch some fog the other day. I mist!"
]

The ^rand function is in fact a shuffle: if the input is repeated four times, each will have a different answer.