Search code examples
aimlprogram-o

Check 2 values in aiml file


How can I check 2 values in condition or with other tags? I want check if the user's name is equal with Unknown user value but I don't know how can I do this.


Solution

  • Assume you have the user name stored in a global property (predicate) called user, using <set name="user">George</set> You can check the user's name with an AIML category like this:

    <category>
      <pattern>WHAT IS MY NAME</pattern>
      <template>
        <condition>
          <li name="user" value="unknown">You haven't told me your name</li>
          <li name="user" value="">You haven't told me your name</li>
          <li>Hello <get name="user"/>!</li>
        </condition>
      </template>
    <category>
    

    This works as follows:

    1. You set up a category that responds to user input "What is my name"
    2. The <li> elements in the <condition> test the name property for unknown and blank. In this case the AI replies the user hasn't told us their name.
    3. The final <li> element is triggered if we have a name, and it replies with 'Hello' followed by the user name.

    I haven't tested this with program O but it's standard AIML and should work fine. I have successfully coded similar categories in my own AI.