AIML and Chatbot Theory – Part Three
TAG <think>
Suppose we want to perform configuration actions in AIML but we do not want the system to give feedback to the user. In that case we can use the tag <think> which will allow the bot to perform operations in the “background”. Let’s give an example to better understand the concept.
<category> <pattern>MY NAME IS *</pattern> <template>What a nice name! <set name="nome"><star/></set> </template> </category>
In the previous example, given the input
user : my name is Domenico
the bot will respond
bot: What a nice name! Domenico
and the variable name=”nome” will be set
but if we used the tag <think> the result would be slightly different.
<category> <pattern>MY NAME IS *</pattern> <template>What a nice name! <think><set name="nome"><star/></set></think> </template> </category>
in this second example when the user types
user : my name is Domenico
the bot will respond
bot: What a nice name!
and the variable name=”nome” will be set
In short, we can always use the <think> tag inside the template to make AIML configuration operations silent to the user.
TAG <random> : random response
It is possible to configure the bot so that it can respond randomly to the same input, providing different answers. To achieve this result you can use the random element, inside which the various responses are contained in li elements:
<category>
<pattern>GOODBYE</pattern>
<template>
<random>
<li>See you soon.</li>
<li>Hello.</li>
<li>Goodbye.</li>
</random>
</template>
</category>
TAG <that> : related response
As you have probably already noticed, the AIML tags examined so far allow us to write atomic rules that do not take into account the dialog history. This limitation is partly overcome by using the <that> and <topic> tags. The <that> tag allows the bot to select a rule and provide a reply based on the previous one, while the <topic> tag makes it possible to activate a subset of rules embedded within the context/topic configured dynamically. Let’s try to understand these two tags with examples.
<category> <pattern>repeat what you said</pattern> <template>sure, I said: <that/></template> </category>
With the previous example I can use the empty <that/> as a variable to retrieve the bot’s last reply, but a category can, however, be conditioned by the previous reply. Let’s see how this is possible in the following example:
<category> <pattern>WHAT DO YOU MEAN</pattern> <that>DO YOU KNOW SOMETHING I SHOULD KNOW</that> <template>I mean that you have hidden something from me!</template> </category>
In this case we suppose that the dialog system has reached a point where it produced, as output, a sentence like: “Do you know something I should know?”. Then the external interlocutor responded with: “What do you mean?”. At this point, the dialog system finds the match with the pattern “COSA INTENDI”, but provided that the context, that is the previous response, is actually that one, it returns the output shown in the example. So here, the that element contained in category serves to define a stimulus that is conditioned on a previous response.
<<AIML and chatbot theory – Second part
AIML and chatbot theory – Part Four >>

Comments