AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Ensure all options of <random> are displayed before repeating
 
 

I wish to answer the bot in various different ways for the same question… currently I am using <random> but then often the same option is returned in succession, that is a poor user experience.

Is there a way to tell random to not show the same option unless all have been shown once?

If that is not possible, I am even ok with a sequential selection of options… please advise?

I am planning to do that by using a var and then <condition> but it there a better way?

 

 
  [ # 1 ]

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.

 

 
  [ # 2 ]

Thank you Dave.

This was precisely how I was planning to do… had posted this hoping that we could do in some better way… mainly retaining the randomness too because here I would then have a cycle setting it to empty as below:

        <li value=“2”>
          <think><set name=“mysequence1”></set></think>
          This is the last response in the sequence, so setting to blank so that it starts from the first.
        </li>

But then the same sequence everytime is a little boring.

 

 
  [ # 3 ]

Another idea… you could nest a couple random responses within each progressive condition.

 

 
  login or register to react