Skip to content

AIML Tutorial

Keith Sterling edited this page Apr 20, 2017 · 27 revisions

All AIML files start the same way, with an XML declaration and a root level tag

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

When you boil it down to the basics, all AIML interactions are made up of 2 parts, a question and an answer. Each interaction is called a 'category', the question is a 'pattern' and the 'answer' is a template. These take the form like

<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
    <category>
        <pattern>HELLO</pattern>
        <template>Hi there!</template>
    <category>
</aiml>

AIML uses the pattern to match the incoming text you type into Y-Bot, and if it finds a match it prints out the template.

You can build a lot of simple questions and answers with this form, but it becomes unmanageable when you get to very large numbers. You end up repeating yourself and trying to guess every possible combination of a question someone might ask.

Clone this wiki locally