Hi and welcome, Aadhyant!
I’m afraid that you’re running into one of the things with AIML that is behind other chatbot engines. The <random> tag is just that: random, which means that there’s a chance that you’ll get repeat responses from time to time. You can use a <condition> tag and a series of <set> tags to cycle through the responses in sequence, but that’s not exactly ideal, either. This is an example of how you might use the <condition> tag:
<category>
<pattern>*</pattern>
<template>
<condition name="mysequence1">
<li value="0">
<think><set name="mysequence1">1</set></think>
This is the second response in the sequence.
</li>
<li value="1">
<think><set name="mysequence1">2</set></think>
This is the third response in the sequence.
</li>
<li value="2">
<think><set name="mysequence1">3</set></think>
This is the last response in the sequence.
</li>
<li>
<think><set name="mysequence1">0</set></think>
This is the first response in the sequence.
</li>
</condition>
</template>
</category>
Notice that the “first” response is actually the last one on the list, and that it also does not have a specific value within the <li> tag to look for. This is intentional for a couple of reasons. first off, this allows for previously unset values for the variable “mysequence1”. Secondly, since that <li> tag has no value assigned to it, it’s an automatic match, and will always work, so it serves as a “fallback” response in the case that all of the other values “fail”. If you were to put that <li> tag without a value at the top of the list, none of the other ones would have a chance to work, since once the AIML interpreter finds a matching element, it uses that for the response and ignores the rest.