Quick Links

Download

Advertisements

AIML File Creation Tutorial

Introduction

In this tutorial you will learn how to create an AIML file.


Free Shipping on Most Orders

AIML Files

An AIML file is simply an XML file. XML files are made up of human-readable text and can be written using any text editor at all. Most AIML files have the extension ".aiml", but they are still readable in notepad and other text editors.


XML files are text files containing tagged information. Tags are surrounded by < and > signs just like HTML tags. AIML files in particular, have their own set of predefined tags that are supposed to be used to define the input/output process for a chatbot.


An AIML file always begins with <aiml> and ends with </aiml>. Between these start and end tags comes a series of <category> tags containing one <pattern> tag and one <template> tag. The basic format of an AIML document is:

   <aiml>
      <category>
         <pattern> ... </pattern> 
         <template> ... </template>
      </category>
      <category>
         <pattern> ... </pattern> 
         <template> ... </template>
      </category>
      <category>
         <pattern> ... </pattern> 
         <template> ... </template>
      </category>
   </aiml>
					

The <template> tag is one of the foundational AIML tags and is always paired with a <pattern> tag. The pattern defines input that the AI (chatbot) needs to watch for and the template defines the AI's response to that input. So, given the following AIML document:

   <aiml>
      <category>
         <pattern> HELLO </pattern> 
         <template> Hi!  How are you? </template>
      </category>
   </aiml>
					

An artificial intelligence will wait for the user to input "Hello" and would respond by saying "Hi! How are you?" The method in which this exchange occurs is up to the programmer for the bot. The most often used method is an exchange of pure text (see A.L.I.C.E. Bot for an example of bot communication). There are also many bot hosting websites like PandoraBots that will host a bot and allow the user simply upload their database of AIML files to define how the bot responds.


Another way to allow the exchange to occur is through speech. One way to do this is to overlay a text-to-speech (TTS) engine over an existing bot. Festival is a free TTS engine available on Linux, on Windows an AI programmer can use the Microsoft Speech API (SAPI).


There are many ways to exchange information between a human and a chatbot, and new ways are being invented all the time. It is important to choose a method that fits your needs and work from there. In the next tutorial, we will be discussing optimizations to the AIML language.


< Prev Tutorial     Next Tutorial >



About the Author

Grant Dryden works as a computer engineer. He writes software in C and C++ for embedded systems as well as firmware in VHDL. He has a Bachelor of Science in Computer Engineering.