-
Notifications
You must be signed in to change notification settings - Fork 135
Tutorial Random Selection
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!
The <li>
tag can contain any other template tags, which provides the option to build complex conditional and logic statements. In the example below HELLO is expanded to add a little more variance and humanism to the response.
<category>
<pattern>
HELLO
</pattern>
<template>
<random>
<li>Hello!</li>
<li>Hi there!</li>
<li>Greetings!</li>
<li>Hiya!</li>
<li>
<think><set name="dayphase"><srai>DAY PHASE</srai></set></think>
<condition name="dayphase">
<li value="Morning">Good morning.</li>
<li value="Noon">Good afternoon.</li>
<li value="Afternoon">Good afternoon.</li>
<li value="Night">Good evening.</li>
<li>Hello!</li>
</condition>
</li>
</random>
</template>
</category>
For a detailed description of the random tag, see the Wiki page Random
Email: [email protected] | Twitter: @keiffster | Facebook: keith.sterling | LinkedIn: keithsterling | My Blog
- Home
- Background
- Guiding Principles
- Reporting an Issue
- Installation
- You And Your Bot
- Bots
- Clients
- Configuration
- AIML
- Sentence Splitting
- Natural Langauge Processing
- Normalization
- Spelling
- Sentiment Analysis
- Translation
- Security
- Hot Reload
- Logging
- Out of Band
- Multi Language
- RDF Support
- Rich Media
- Asynchronous Events
- Triggers
- External Services
- Dynamic Sets, Maps & Vars
- Extensions
- Pre & Post Processors
- Custom Nodes
- The Brain Tree
- Utilities
- Building It Yourself
- Creating Your Own Bot
- Contributing
- Performance Testing
- FAQ
- History
- Website