<condition> Tag is similar to switch statements in programming language. It helps ALICE to respond to the matching input.
<condition name = "variable-name" value = "variable-value"/>
For example, consider the following conversation.
Human: How are you feeling today Robot: I am happy!
Here we've stored happy as the state of ALICE and that is how it responds as "I am happy!".
Create condition.aiml inside C > ab > bots > test > aiml and condition.aiml.csv inside C > ab > bots > test > aimlif directories.
<?xml version = "1.0" encoding = "UTF-8"?> <aiml version = "1.0.1" encoding = "UTF-8"?> <category> <pattern> HOW ARE YOU FEELING TODAY </pattern> <template> <think><set name = "state"> happy</set></think> <condition name = "state" value = "happy"> I am happy! </condition> <condition name = "state" value = "sad"> I am sad! </condition> </template> </category> </aiml>
0,HOW ARE YOU FEELING TODAY,*,*, <think> <set name = "state"> happy</set> </think> <condition name = "state" value = "happy">I am happy!</condition> <condition name = "state" value = "sad">I am sad!</condition>,condition.aiml
Open the command prompt. Go to C > ab > and type the following command −
java -cp lib/Ab.jar Main bot = test action = chat trace = false
You will see the following output −
Human: How are you feeling today Robot: I am happy!