This documentation supports the 20.02 version of Live Chat. To view an earlier version, select the version from the Product version menu.

Specifying answers in the <template> element of AIML


The template is one of the three standard elements in Artificial Intelligence Markup Language (AIML). It contains the response of a chat robot (chatbot) to the user's question. The template element includes basic text formatting, conditional response (if-then/else), and random responses. For more information, see AIML-structure

The answers in the template tag can be used in the following ways:

Reusing answers in the <template> element of AIML

Users might ask the same question in different ways. The AIML file should include as many phrases as possible to respond to the user. For example, a user might phrase a question about a change in their email in any of the following ways:

  • Will my email address change in Google mail
  • Google email change
  • Email address change

In AIML, you can reuse answers by using the <srai> element. This element allows one answer to be coded and referenced by multiple questions. The <srai> element points to the <pattern> element (question) that contains the <template> element (answer) as shown in the following example:

<category> 
 <pattern>Google email change</pattern> 
 <template>Your email address won't change! You'll continue to receive all your email at your current email address.</template> 
</category> 
<category> 
 <pattern>Will my email address change with Google mail</pattern> 
 <template><srai>google email change</srai></template> 
</category> 
<category> 
 <pattern>* Email address change * Google *</pattern> 
 <template><srai>google email change</srai></template> 
</category> 

Adding multiple answers in the <template> element of AIML

You might want to provide multiple answers to a question. For example, a user might want to know the leading news websites. The following example shows how to use the <random> element to provide multiple answers in one <template> element:

<category>
 <pattern>What are the best news websites</pattern>
 <template>
     <random>
         <li>www.cnn.com</li>
         <li>www.msnbc.com</li>
         <li>news.google.com</li>
         <li>www.foxnews.com</li>
     </random>
 </template>
</category>

Related topics

AIML-introduction

Using-AIML-with-BMC-Live-Chat

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*