Manual:Verbot Editor Variables
From VerbotWiki
| Table of contents |
My name is [username], do you remember me?
Variables help the Verbot remember things about you. Some variables can even be setup to remember things like phone numbers, family members and more.
The easiest way to understand Variables is by looking at an example. Let's start by learning how a Verbot remembers your name.
Understanding What Variables do.
When a user first speaks with a Verbot, the Verbot doesn't know the user's name. For example, if you asked the Verbot "What is my name?" it would most likely respond with "Your name is Friend."
However, if you told the Verbot "My name is Mary" the Verbot would respond with "It's nice to meet you Mary."
The Verbot now knows that your name is Mary. If you were to ask "What is my name?" the Verbot would now respond "Your name is Mary."
What is my name?
Let's look at a sample response in which the Verbot does not know your name. "What is my name" Rule first - so we can see how the Verbot responds with "Friend" if it doesn't know your name.
Rule Name: What is my name Input: (what is) my name Output: Your name is [name:Friend].
Note: (what is) <-- is a Synonym. Click Here to find out more about Synonyms
You might have noticed that before you tell the Verbot your name, it call you "Friend". The Verbot uses "Friend" because the Variable "name" is not set.
The following example shows a Variable with the default setting of "Friend". You can of course replace "Friend" with anything you like (or not use an alternate at all, which would return nothing).
Example:
Your name is [name:Friend].
My name is [name]
We now know that if a variable is not set it will use alternate text if available, but how do we set the Variable? It's actually rather simple. Let's look at the Rule "My name is [name]."
Rule Name: My name is [name] Input: My name is [name]. Output: Good to meet you [name]!
The Variable "[name]" that is found within the Input "My name is [name]," tells the Verbot to record whatever text the user types in the place of "[name]."
The [name] within the Output simply prints out the text that was captured in the Input. Having the Verbot repeat back what it has captured not only makes the conversation with the Verbot more realistic, but it also makes it more personal.
For example, if you type "My name is Mary." the Verbot will respond "Good to meet you Mary!" and the Variable [name] is stored with the value of "Mary." From that moment on, whenever the Verbot finds the variable [name], it will display "Mary" in the output.
Variables in Variables: "Joe's phone number is 555-5555"
There are times when you want to save information, such as recording your friend's telephone numbers. To do this, you need to use Variables inside other variables.
Saving Joe's Number, and Jenny's, and John's, and Juan's too!
In the Rules above, you learned how to save a single name (Mary) to a single Variable ([name]). However, to save multiple phone numbers we'll need multiple Variables. How do you that with a single Rule? Let's find out.
Rule Name: Save Phone Number
Input: [contactname]'s phone number is [[contactname]s_phone]. Output: I'll try to remember that [contactname]'s phone number is [[contactname]s_phone].
The Rule above contains [contactname] which is a Variable exactly like the [name] Variable we used before. However, you'll notice that there is another Variable in the Input which uses [contactname] within itself. [[contactname]s_phone] is a Variable within another Variable. We use the first Variable "[contactname]" to create a unique variable which can be retrieved by a different Rule.
Let's see what happens when you type the following Input: "Joe's phone number is 555-5555."
First, thing that happens is "Joe" is stored within the Variable "[contactname]."
Now that "Joe" is stored within the Variable "[contactname]," the Verbot can then use "Joe" within another Variable. In this case, "[[contactname]s_phone]" is set to the Variable name of "Joes_phone" with the value of "555-5555".
So, here is what you end up with:
contactname = "Joe" joes_phone = "555-5555"
Note that is you typed in the same sentence using a different friend' information, you would get another unique variable. For example, if you typed in "Jenny's phone number is 555-8888." The Variables would be as follows:
contactname = "Jenny" jennys_phone="555-8888"
Notice that contactname is always set to the last Input (Jenny) but a unique variable is created (jennys_phone).
Retrieving the Variable: "What is Joe's phone number?"
Using the example above - we have two Variables available: joes_phone and jennys_phone. To access the Variables we create the following Rule:
Rule Name: Get Phone Number
Input: What is [contactname]'s phone number?
Output: [contactname]'s phone number is [[contactname]s_phone].
That's it. Now to access Jenny's number you would type "What is Jenny's phone number?"
Note: It would be a good idea to add other inputs so that it'll match to phrases such as "give me Jenny's number" or simply "Jenny's number."


