Skip to content

Tutorial Random Selection

Keith Sterling edited this page Oct 2, 2017 · 10 revisions

Randomness

The <random> tag allows the AIML developer to add a level of 'humanness' to the response to any question. It provides the ability to respond in multiple different ways to the same question. A random tag is made up of one or more 'list items' or <li> tags. Each list tag can contain anything that you would normally place within a template tag.

If the example below we have decided to provide a random response to the question HELLO.

<category>
    <pattern>HELLO</pattern>
    <template>
        <random>
            <li>Hi there!</li>
            <li>Hiya</li>
            <li>Hello there</li>
            <li>Yo!</li>
        </random>
    </template>
</category>

Adding this grammat to your bot and running the console, you can now ask Hello and receive a random response as follows.

Loading, please wait...
No bot root argument set, defaulting to [.]
Y-Bot version 0.0.1, initiated March 14, 2017
Hi, how can I help you today?
>>> Hello
Hiya
>>> Hello
Hi there!
>>> Hello
Yo
>>> Hello
Hi there!

In future steps of the tutorial, we will show that by mixing random and conditional statements in the same template response you can provide a higher level of humanness by creating contextual and/or non-deterministic responses.

For a detailed description of the random tag, see the Wiki page Random


Back to Tutorial | Back - Sets | Next - Symbolic Reduction

Clone this wiki locally