Manual:Verbot Editor Using Virtual Child Rules

From VerbotWiki

Virtual Child Rules are used to link Rules to other Rules, virtually! The best way to understand how Virtual Child Rules work is through a tutorial to see them in action.

Example 1: All I want from you is a straight answer!

In the following example, you'll learn how to have the Verbot ask a question and receive one of three possible Inputs from the User.

We'll start by creating a _startup Rule. A _startup is a special Input that the Verbot looks to fire when it is first loads.

Image:Ve_tut_virtualchild1.png

You can see that the _startup Rule has the Input "_startup" and the Output "Hi! Would you like to take a quick quiz?" Next, we'll make a few Child Rules. One for the Input "yes," one for "no," and one that will fire if there is no match.

Image:Ve_tut_virtualchild2.png

As you can see above the _startup Rule now has three Child Rules. Here is what each Rule contains so far:

_startup Input: _startup Output: Hi! Would you like to take a quick quiz?

anything else Input: * Output: I'm sorry. I really need a "Yes" or "No" Answer.

no Input: no Output: Okay no problem.

yes Input: yes Output: Great. Let's get started! What is the name of the planet most people live on?

Okay let's test it. Click on "Tools" --> "Test KnowledgeBase"

The _startup Rule will fire and display: "Hi! Would you like to take a quick quiz?"

Image:Ve_tut_virtualchild3.png

Now, if you were to type "yes" or "no," the appropriate Child Rule would fire. However, if you were to send the Input "maybe" - the only Child Rule that would match would be the Rule "anything else" using the Input "*" with the Output "I'm sorry. I really need a "Yes" or "No" Answer."

Image:Ve_tut_virtualchild4.png

The problem we would have if you answered the Verbot with "yes" or "no" after the "anything else" Rule has fired - is that there are no Child Rules for the "anything else" Rule. This is where Virtual Child Rules come in.

Close the Verbot Script Tester window. Click on the Rule "anything else" to select them and then click on the "Virtual Child" button. The Rule Activation List window will pop up.

Image:Ve_tut_virtualchild5.png

"Click" on the check box for the following Rules: "anything else", "no" and "yes".

Image:Ve_tut_virtualchild6.png

Once you've selected all three Rules click on "Ok". To test the Script open the "Verbot Script Tester" ("Tools" --> "Test KnowledgeBase") and test the KnowledgeBase again.

Type in the Input "maybe".

As before your Input of "maybe" fires the "anything else" Rule with the Output: "I'm sorry. I really need a "Yes" or "No" Answer."

The Verbot will keep firing the "anything else" Rule until the Input of one of the Virtual Child Rules is received ("no" or "yes").

Once "no" or "yes" is received by the Verbot, it will look for another Child Rule. If a Child Rule is not found it will search through the Primary Rules.