AIML introduction

By Steven | December 27, 2019

What is AIML

AIML stands for Artificial Intelligence Markup Language. AIML was developed between 1995 to 2002 in creating or customizing Alicebot which is a chatbot application based on A.L.I.C.E (Artifical Linguistic Internet Computer Entity). AIML is an XML dialect and very easy to use but not powerful as modern intelligent chatbots these days. AIML is a widely adopted standard for creating chat bots and mobile virtual assistants.

Elements of AIML

AIML contains several primary elements. The most frequently used elements are Category, Pattern, and Template. AIML files use the extention .aiml to hold those bulk of codes.

  • <set>-Tag (Used to set value in an AIML variable)
  • <star>-Tag (Used to match wild card * character(s) in the Tag)
<category><pattern><SET>COLOR</SET></pattern>
<template><star/> is a color.</template>
</category>

which will give us the message below:

Human : red
Robot : red is a color.
  • <srai>-Tag (Multipurpose tag, used to call/match the other categories)
  • <think>-Tag (Used in AIML to store a variable without notifying the user)
<category><pattern>DO YOU LIKE PUPPIES</pattern>
<template><srai>DO YOU LIKE DOGS</srai></template>
</category>
...
<category><pattern>DO YOU LIKE DOGS</pattern>
<template><think><set name="them"><set name="topic">Dogs</set></set></think> I like friendly dogs.</template>
</category>

which corresponding to the message below:

Human : do you like puppies?
Robot : I like friendly dogs.
  • <random>-Tag (Get random responses)
  • <li>-Tag (Used to represent multiple responses)
<category><pattern>ARE YOU</pattern>
<template><random>
<li>Glad you asked.</li>
<li>I'm here to support you.</li>
<li>What would allow you to relax right now.</li>
</random></template>
</category>

which is corresponding to the message:

Human : Are you
Robot : What would allow you to relax right now.
Human : Are you
Robot : What would allow you to relax right now.
Human : Are you
Robot : I'm here to support you.
  • <get>-Tag (Used to get value stored in an AIML variable)
<category><pattern>ARE YOU CALLING ME A *</pattern>
<template>No I call you <get name="name"/>.</template>
</category>

we got:

Human : Are you calling me a dog?
Robot : No I call you Friend.
  • <that>-Tag (Used in AIML to respond based on the context)
   <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> 

we got the following response:

Robot : Do you like comedy movies
Human : No
Robot : Ok! But I like comedy movies.
Human : Yes
Robot : Um.
Human : what about movies
Robot : Do you like comedy movies
Human : Yes
Robot : Nice, I like comedy movies too.
  • <topic>Tag is used in AIML to store a context so that later conversation can be done based on that context.
   <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>

then, we got the following conversation:

Human : Let discuss movies
Robot : Yes movies
Human : Comedy movies are nice to watch
Robot : Watching good movie refreshes our minds.
comments powered by Disqus