chatbotaiml

Aiml values not matching


In aiml i am not getting the condition values which i have assigned. i'm getting unknown answers here is my code:

<category>
    <pattern>ask me question</pattern>
    <template>
 let look <srai>QUESTION</srai>
</template>
</category>

<category>
    <that>let look *</that>
    <pattern>*</pattern>
    <template>
      
      <think>
          <set name="letlook"><star/></set>
      </think>
      
          <condition name="letlook">
            <li>no that is not right</li>
            <li value="phone"><think><set name="letlook">phone</set></think> right</li>
        </condition>
        </template>
</category>


<category>
    <pattern>QUESTION</pattern>
    <template>
        What never asks a question but gets answered all the time?
          <think>
<set name="letlook">phone</set></think>
</template>
</category>

i want it to respond like this

Human: ask me question
Robot: What never asks a question but gets answered all the time?
Human: Phone
Robot: Right

but i am getting this response

Human: ask me question
Robot: What never asks a question but gets answered all the time?
Human: Phone
Robot: no that is not right

How to fix this code? any help is appreciated.


Solution

  • list items in conditions are matched from top to bottom. Your condition will always produce the first answer, as you haven't provided a value, and so it always matches. Swap the <li> elements around and it will work.

        <condition name="letlook">
            <li value="phone"><think><set name="letlook">phone</set></think> right</li>
            <li>no that is not right</li>
        </condition>
    

    Oh, and you don't need to set "letlook" to "phone" in your li as it will already have that value.