Open In App

AIML Introduction

AIML (Artificial Intelligence Markup Language) is a description language used in the development of natural language software agents like chatbots and virtual assistants. AIML was developed by Richard Wallace from 1995 to 2000, and it is based on XML (eXtensible Markup Language). AIML provides automated responses to users’ questions because it is rule-based. The scripting language represents a data-driven programming paradigm. While writing the script for a conversational chatbot, all the conditions (the user’s query) and actions (the chatbot’s response) must be included.

Features of AIML

AIML Tags and their syntax

There are multiple elements and tags in AIML and we are going to see some basic elements with their syntax.

1. <aiml>: Inside this tag, all tags are defined. It constructs the starting and ending of an AIML document.



<aiml> <!-- all the tags that contain conditions and actions--> </aiml>

2. <category>: inside each category tag defines conditions and actions. category tags can be multiple inside the <aiml> tag.

<aiml>
<category>
<!--condition and action are defined-->
<category>
</aiml>

3. <pattern>: The condition is written inside the pattern tag.

<aiml>
<category>
<!--condition and action are defined-->
<category>
</aiml>

4. <template>: The action is written inside the template tag. Actions can be single or multiple, so the template tag is defined multiple times inside the category tag.

<aiml>
<category>
<pattern> <!--condition is defined--> </pattern>
<template> <!--Action is defined for condition--> </template>
<category>
</aiml>

AIML Examples

AIML Script is an XML Document, that contains elements defined using AIML schema. It must contain only one <aiml> element. The conditions and actions are defined within <category> element. For condition, <pattern> tag is used and for action, <template> tag is used.

Example 1: In this example, the condition is Hello and for that condition, the action is Hi, how can I help you? you can include multiple conditions and actions using multiple <category> elements.




<?xml version="1.0" encoding="UTF-8"?>
<aiml>
    <category>
        <pattern>Hello</pattern>
        <template>Hi, how can I help you</template>
    </category>
</aiml>

Output: 

Example 2: In this example, we just continue the same process with another example by taking the chat process further.




<?xml version="1.0" encoding="UTF-8"?>
<aiml>
    <category>
        <pattern>Hello, I need some help</pattern>
        <template>Hi, how can I help you</template>
    </category>
    
    <category>
        <pattern>How to learn JavaScript</pattern>
        <template>You can learn JavaScript from its official documentation</template>
    </category>
</aiml>

Output: 

Applications of AIML

Advantages of AIML

Disadvantages of AIML

Conclusion

The conclusion of the article is that AIML is a developer-friendly scripting language used for creating chatbots and assistance based on XML document syntax. Every NLP-based agent developer needs to learn this AIML description language. Simple chatbots can be easily created, but for complex tasks, AIML has some limitations. Still,  AIML is a very good choice for creating conversational basic chatbots.
 


Article Tags :