What is AIML (Artificial Intelligence Markup Language)?

AIML (Artificial Intelligence Markup Language) is an XML-based language to begin customising an Alice-bot or creating Chat-Robot from scratch. It was developed by Dr. Richard Wallace for chatterbox called “A.L.I.C.E.” (“Artificial Linguistic Internet Computer Entity”)[1][2]

The most important units of AIML are:

  1. <aiml>: the tag that begins and ends an AIML document.
  2. <category>: the tag that marks a “unit of knowledge” in an Alicebot’s knowledge base. Every new question or Pattern with its relevant answer goes in this tag.
  3. <pattern>: used to contain a simple pattern that matches what a user may say or type to an Alicebot.
  4. <template>: contains the response to a user input. WE can have n-number of templates as per response.
  5. <star>:  Tag is used to match wildcard * character(s) in <pattern> Tag.
  6. <srai> Tag is a multipurpose tag. This tag enables AIML to search pattern for the same template. It helps us to reduce complex grammatical pattern in the simple pattern. It performs the recursive  operation.  
  7. <random>: Tag is used to getting random responses. This tag enables AIML to respond differently to the same input. <random> tag is used along with <li> tags. <li> tags carry different responses and Responded any one of them randomly.
  8. <set> and <get>: tags are used to work with variables in AIML to Set and Get Value from same.
  9. <that>: Its follow-up Response for any pattern. Support like if..Then..Else kind for behavior.
  10. <topic> Tag is used in AIML to store a context so that later conversation can be done based on that context.
  11. <think> Set value without notifying the user. <set> will Display name, but to override display we use <think>.
  12. <condition> Tag is similar to switch statements in the programming language.
Example 1 

<?xml version = "1.0" encoding = "UTF-8" ?>

<aiml version = "1.0.1" encoding = "UTF-8"?>

   <category>

      <pattern> HELLO Mansi </pattern>

      <template>

         Hello Dear !!!

      </template>

   </category>

</aiml>

<aiml…> is Parent tag for AIML Script.  Here we have created first <category>, which contain two tags first <pattern> and <template>. <pattern> is pattern we are accepting from user, if user matches such  sequence of word like “Hello Mansi” then <template>  “Hello Dear !!!” comes as respose.

Example 2 

<category>

   <pattern> I am * </pattern>

   <template>

   Hello Dear, <star index = "1"/>

   </template>

</category>

Here * and <star index=”n”>, Provides facility to use user enters keyword to popup as templates. For Example if user Enters: “I am Jignesh”, Response will be “Hello Dear, Jignesh”.

 

Example 3

<category>

   <pattern> Bye </pattern>

   <template> Ta Ta !!! </template>

</category>

<category>

   <pattern>Good Bye</pattern>

   <template><srai> Bye </srai></template>

</category>

 

In this Example, Both the input “Bye” and “Good Bye” will produce Same output “TA TA !!!”.

Example 4

<category>

      <pattern>HI</pattern>

      <template>

         <random>

            <li> Hello! </li>

            <li> Hi! </li>

         </random>

      </template>    

   <category>      

Here, User input will be “HI” and Response generated any one from “Hello!” or “Hi” randomly.

Example 5

<category>

      <pattern>I am *</pattern>

      <template>

         Hello <set name = "username"> <star/>! </set>

      </template>  

   </category>  

   

   <category>

      <pattern>Good Bye</pattern>

      <template>

         Bye <get name = "username"/>

      </template>  

   </category>

Here, User Enter his/her name, we will store it for temporary purpose in Variable name “username”. If the user enters “I am Jignesh” System will respond “Hello Jignesh” also set variable username=Jignesh. At “Goodbye” Pattern system will respond “Bye Jignesh”.

 

Example 6

<category>

      <pattern>WHAT ABOUT MOVIES</pattern>

      <template>Do you like comedy movies</template>  

   </category>

   <category>

      <pattern>YES</pattern>

      <that>Do you like comedy movies</that>

      <template>Nice, I like comedy movies too.</template>

   </category>

   

   <category>

      <pattern>NO</pattern>

      <that>Do you like comedy movies</that>

      <template>Ok! But I like comedy movies.</template>

   </category>

The user will ask about movies, Then System will backfire question “Do you like comedy movies”. If user Response with “Yes” then system will respond “Nice, I like comedy movies too.” Or if User response “No” then “Ok! But I like comedy movies.”

 

Example 7

<category>

      <pattern>LET DISCUSS MOVIES</pattern>

      <template>Yes <set name = "topic">movies</set></template>  

</category>

   

<topic name = "movies">

      <category>

         <pattern> * </pattern>

         <template>Watching good movie refreshes our minds.</template>

      </category>

      <category>

         <pattern> I LIKE WATCHING COMEDY! </pattern>

         <template>I like comedy movies too.</template>

      </category>      

</topic>

 

Example 8

<category>

      <pattern>My name is *</pattern>

      <template>

         Hello!<think><set name = "username"> <star/></set></think>

      </template>  

</category>     

<category>

      <pattern>Byeee</pattern>

      <template>

         Hi <get name = "username"/> Thanks for the conversation!

      </template>  

</category>  

  

 

Example 9

<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>

 

Citation

[1] http://www.alicebot.org/aiml.html, as on 13 October 2016

[2] https://en.wikipedia.org/wiki/AIML as on 13 October 2016

[3] https://www.tutorialspoint.com/aiml/aiml_that_tag.htm as on 13 October 2016

Share Post

  • Shruti Iyyer

    How can we call custom methods in java as per user input in alice 2 aiml Sir?

    • jig4physics

      DEAR reader,

      If you want to execute any program from AIML , then you can use shell script (.Sh) or webservice.