tengku adrianna
tengku adrianna

Reputation: 1

one pattern multiple responses in aiml inorder

I want the user to have a single response to multiple answers in order. Is there any way to write it other than <random>.

<category>
    <pattern> WHY IS KNOWING THAT USEFUL</pattern>
    <template>
        <random>
    <li> 
        The fourth word in this question is an example of how some words can only be understood in context.
    </li>
    <li>
        I have no answer for that.
    </li>
    <li>
         Because it allows us to make statements that apply to classes of things or questions.
    </li>
    
</random>
    </template>
</category>

In order like this

Upvotes: 0

Views: 80

Answers (1)

Steve Worswick
Steve Worswick

Reputation: 905

Rather than using random, you need to keep a count of how many times the user has called the category, display the next answer in the list and then increase the counter by 1. The counter should be reset to 0 after all the responses, so it cycles through them again:

<category>
  <pattern>WHY IS KNOWING THAT USEFUL</pattern>
  <template>
    <condition name="count">
      <li value="0"><think><set name="count">1</set></think>Answer 1.</li>
      <li value="1"><think><set name="count">2</set></think>Answer 2.</li>
      <li value="2"><think><set name="count">0</set></think>Answer 3.</li>
      <li><think><set name="count">1</set></think>Answer 1.</li>
    </condition>
  </template>
</category>

Two things to note.

  1. We add a catchall at the end, as when you first hit the category, the counter has no value, so we set it to 1 and display the first answer.

  2. If you have more than one of these sequential categories, you will need a different name for each "count" or they will clash.

Upvotes: 0

Related Questions