chatbotaiml

AIML multiple patterns with one response


Lets say I want the user to have a single response to multiple greetings for the bot. Is there a better way to write this using an "or" statement or a list instead of writing each case out with all the templating like this to redirect the pattern?

<category>
    <pattern> HELLO</pattern>
    <template>
        Hello User!
    </template>
</category>

 <category>
    <pattern> HI</pattern>
    <template>
        <srai> HELLO</srai>
    </template>
</category>

     <category>
    <pattern> HOWDY</pattern>
    <template>
        <srai> HELLO</srai>
    </template>
</category>

Solution

  • You could create a set called "greetings" containing the different ways of saying hello, like this:

    enter image description here

    And then write this category:

    <category>
        <pattern>^ <set>greetings</set> ^</pattern>
        <template>Hello User!</template>
    </category> 
    

    But to me, it's far easier to make new categories for each option and <srai> to your main one, as in your original example.